This Is Driving Me Crazy

I'm trying to triangulated and delete history on a scene and then output it to the Indigo render. Then I want to undo history back to the previous state in order to keep my history and quad polysmesh. How do I simply undo these two steps? It seems so easy.

Here is my code:

CODE
/* Description: Triangulates and deletes history then undoes the process. */
//------------------------------  
global proc triangulateIndigoRender ()  {
SelectAllPolygonGeometry;  
string $triangulateMe[] = ls-sl;
string $objectToTriangulate;  
for ($objectToTriangulate in $triangulateMe)
{     
polyTriangulate $objectToTriangulate;     
}
DeleteHistory; }
//------------------------------
global proc triangilateIndigoExport ()  {
renderIntoNewWindow render; }
//------------------------------  
global proc triangilateIndigoUndo ()  {
undo; }

Of course I have tried many other approaches for the undo section, like undoinfo and others, but to no success.

Thanks for any help.

yes wel theres no sane reason youd ever want to do this tough. Why the hell would it mater if you flush the hitory or not?

The reason I want to do this is because:

In order to render using the Maya to Indigo script (www.indigorender.com) I need to convert all my meshes to tris and also delete history on all objects.

Then the scene is exported to the Indigo standalone renderer. It is confusing in my script because currently I am just rendering in Maya as a test. You can just disregard this part:

CODE
global proc triangilateIndigoExport ()  
{
renderIntoNewWindow render;
}

Then I want to have my script set everything back to the state it was before my script started. For example, the meshes would be quads and have history in case I want to edit them more.

I do realize that I could hit the "z" key every time I want to render, but I would rather just build it into my script.

Maybe I am looking over something obvious. I would really appreciate any input on this, and also please be specific about the undo features, because I can hardly find any info on it.

Thanks for your response Joojaa and I look forward to get your insight.

Why? what does killing the history have to do with triangulation? I mean if i realy needed cleaned histry WICH i strongly doubt you need (trust me on this one a exterenal prog cant se the difference of history or not). Id leave the histiory as is because then if you rerender the next frame maya does the same again without input.

BUt just in case you cant do this for some INSANELY STUPID design (this must be quite deliberately put there then becasue normaly a inept user couldnt do this) then do this isnetad:

Triangulate unocnnect all the final tri meshes from their history (but DONT DELETE IT), then reconnect.

But as a matter of fact your script should work, but i bet the deign of the indigo script exporter disables and flusghes UNDO so you couldnt use undo in this case. (except you must undo without calling it within a proc sicne otherwise it undoes the undo)

Now however you might want to change teh exporter script instead.

PS i looked into it and the exporter does not actualy require you to flush your history! But whoever did it didnt realy plan the script very well.