Undoing last commit from within Extension

I am trying to undo the last operation when the user enters a new text value after calling a model.start_operation() and model.commit_operation() delimited method (in my case, a method called draw_arc).

I call Sketchup.send_action(“editUndo:”) and call my draw_arc again, but the send_action is an asynchronous call and is not actually performed until after my draw_arc is complete. The net effect is to undo the second call to draw_arc rather than undo the original operation and perform the second.

How can I force the Undo to happen first? Is there a synchronous call? This is like the difference between ‘PostMessage’ and ‘SendMessage’ in the windows API.

The send actions are not meant for anything more than simple menu items or toolbar button commands.

Learn to use the YARD doc interface’s methods list, to find what you need.

image

So it’s the module method …

… not that I’m guaranteeing it’ll make your code work :wink:

Thank you @DanRathBun

I keep that doc open on my 2nd screen but did not see the undo method for the Sketchup class. For my doc searches, I was not selecting Methods before entering my search text.

BTW, that makes my code work as expected :sunglasses:

1 Like

There’s always something else to learn. Keeps life interesting.

(And Sketchup is a module. Ie, we cannot instantiate it.)

1 Like