# Undoing last commit from within Extension

**URL:** <https://forums.sketchup.com/t/undoing-last-commit-from-within-extension/124473>\
**Category:** Ruby API\
**Created:** [May 5, 2020, 4:18pm UTC](https://forums.sketchup.com/t/undoing-last-commit-from-within-extension/124473 "2020-05-05T16:18:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sasquatch](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/sasquatch/32/87863_2.png) [@Sasquatch](https://forums.sketchup.com/u/Sasquatch)\
**Post date:** [May 5, 2020, 4:18pm UTC](https://forums.sketchup.com/t/undoing-last-commit-from-within-extension/124473/1 "2020-05-05T16:18:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [May 5, 2020, 4:43pm UTC](https://forums.sketchup.com/t/undoing-last-commit-from-within-extension/124473/2 "2020-05-05T16:43:27Z")

</div>

> [@Sasquatch](#):
>
> … but the _send\_action_ is an asynchronous call …

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

> [@Sasquatch](#):
>
> How can I force the Undo to happen first? Is there a synchronous call?

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

![image](https://global.discourse-cdn.com/sketchup/original/3X/d/d/ddd82a594b8853966237bac68d92cfb9191322a4.png)

So it’s the module method …

- [**`Sketchup::undo`**](https://ruby.sketchup.com/Sketchup.html#undo-class_method)

_… not that I’m guaranteeing it’ll make your code work_ 😉

---

<div class="post-metadata">

**Author:** ![Sasquatch](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/sasquatch/32/87863_2.png) [@Sasquatch](https://forums.sketchup.com/u/Sasquatch)\
**Post date:** [May 5, 2020, 4:52pm UTC](https://forums.sketchup.com/t/undoing-last-commit-from-within-extension/124473/3 "2020-05-05T16:52:57Z")

</div>

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 🕶

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [May 5, 2020, 4:55pm UTC](https://forums.sketchup.com/t/undoing-last-commit-from-within-extension/124473/4 "2020-05-05T16:55:35Z")

</div>

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

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