PDA

View Full Version : run undo after a script is run


rxgeez
02-01-2011, 01:17 AM
I have a window with a button.....what I want to be able to do is when the button is clicked have it run a proc....then when it finishes undo what the proc just did.

If I add the undo command at the end of my proc it just undos the last thing that was done before the proc ran...the undo queue doesn't get updated till the proc finishes.

here is a simple example:

global proc mySpheres(){
for($i=0; $i<5; $i++){
polyCube;
}
select -cl;
}

global proc createMySpheres(){
mySpheres();
undo;
}

when I run createMySpheres I want it to run mySphere and then undo....but it doesn't work like that. I can manually click undo after createMySpheres runs and it will undo....but I want it to automatically do it for me.

any ideas?

EightBit
02-01-2011, 06:30 AM
Try this:global proc mySpheres(){ for($i=0; $i<5; $i++){
polyCube;
}
select -cl;
}
global proc createMySpheres(){
mySpheres();
}
createMySpheres;
undo;

NaughtyNathan
02-01-2011, 10:24 AM
evalDeferred("undo");This defers 'undo' until all other processing has completed (i.e. your script has totally finished)
:nathaN

rxgeez
02-01-2011, 05:21 PM
Thanks Nathan.....the evalDeferred() command was what I needed.

CGTalk Moderation
02-01-2011, 05:21 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.