Scripting Error
Brahann
Posts: 18
I'm trying to write a very simple script to undo the last action but keep getting a Can't find variable undo error in my undo() call
any ideas
Comments
Sounds like you need to define the undo variable in your code?
You'd probably get more help if you post your script (host it elsewhere since attachments are broken) and perhaps move your post to the scripting forum: https://www.daz3d.com/forums/categories/daz-script-developer-discussion
thanks
I'm trying to write a very simple script to undo the last action but keep getting a Can't find variable undo error in my undo() call
any ideas
Threads merged. Please do not post the same thread in more than forum. It becomes confusing trying to remember what responses got posted where.
If you want to change forums go to your opening post and where the forum name is and select the drop-down and point it to the forum you wish to post it to.
What is the script? It's really hard to troubleshoot from what little information you have given.
I'm trying to write a very simple script to undo the last action but keep getting a Can't find variable undo error in my undo() call
any ideas
Isn't this the third thread you have started on this - still with no extra info?
what extra info basically I just want a script to undo an action such as applying a L.I.E.
any thing I try results in a cant find undo()
e.g.
(function(){
beginUndo();
undo();
acceptUndo("Undo");
})();
gives
Script Error: Line 5
ReferenceError: Can't find variable: undo
Stack Trace: ()@:5
Yes, like I said in your other thread, you have not defined the undo function. e.g.
Threads merged again. If youw ant to move this to the sceripting forunm edit the first post and select the desired forum from the drop-down list.
The built-in undo actuions here are for adding actions to the undo stack, so that they will appear under edit>Undo. If you want to abort an operation then it is up to you to reverse the steps, using your own code, and then cancel the undo creation - if you don't want to cancel then you accept the undo. You snippet would add an entry to the undos tack, even though you had presumably nulled the actions the script had performed.
http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/global
I could be being an absolute idiot here but undo seems to be declared as a method in the dazundo stack the question is how to call it without gettig an error?
Dave
BeginUndo tells Daz Studio to add the current state of the scen to the stack
Then you (try to) do stuff that modifies the scene
Then you AcceptUndo to tell Daz Studio that the process is complete, or if the operation was cancelled or failed you use cancelUndo to tell DS to drop the entry.
Once you have done, and used AcceptUndo, you could I suppose trigger an Undo action - that would clear out any changes your script had made but ti would also leave them available as a redo until soemthing else was added to the stack. Undo within the script is the author's responsibility, as far as I know.
If you literally just want to call the undo function from the stack then you should delete your entire script and replace it with the following:
That one-line script will do what the Undo button / Ctrl-Z does - is that what you wanted to do?
But don't do that in the middle of a Begin/Accept or Cancel block - I think it would, at best, fail.