Next undo / redo operation


Can’t find anywhere how to get next undo / redo operation operation in Sketchup model. I suppose, if it’s visible in ‘Edit’ options, then I can get it through the ruby?
More precisely, I need to get which is the next undo or redo operation.


Access to the undo stack has been requested before but as yet there is nothing in the Ruby API.


Sketchup.undo undos and Sketchup.send_action("editRedo:") redos. Unfortunately the latter is asynchronous and has a somewhat clunkier syntax.


Just to clarify, the method @eneroth3 cited will indeed undo the last operation and the action she cited will indeed redo. I thought the OP wanted to know what operation would be udone or redone, which would require access to the stack itself…

The asynchronous nature is true of all send_action calls. They schedule the operation for execution the next time SketchUp determines it is safe, they do not execute immediately.


You’re right! But I struggle with English, so I’m happy when someone understands me. :hugs: . Hvala @eneroth3 i hvala @slbaumgartner.
About a year I’m trying to learn how to develop Sketchup extensions. I just recently started asking questions in this forum. I did not expect to receive help, not just now, but in general, so quickly and efficiently. Thank you! I hope everything will go this fast and smoothly when my extension is supposed to be approved. :worried:


Please note that the ModelObserver can also tell you when the user (or an extension) triggers and undo or redo :


Yes, but I was interested in getting an operation that needs to be redone / undo. In advance! Like what you see in Sketchup ‘Edit’ options under redo and undo.


That’s what I understood from your post, that was just a side-note in case it could be useful to you :wink:


Yes, I understood your original post this way.

As Steve said, there is no access to the undo stack.
Also there is no exposure of other coder’s (or native) operations as an API object or class.
So for example, we cannot even get the menu text “name” of the operation.


The undo stack is something where extensions can impact each other or even clash (and even if you rely on just reading operation names it can be a source of bugs).
This sounds like you want to do something in a somewhat complicated approach that could be achieved in a cleaner way. If you tell us what you are trying to achieve, maybe we can propose another way to do it?


It is more complicated to explain what I’m doing than find a solution. :slight_smile:
I decided to change the approach so this does not matter anymore. But I just wanted to follow my operations. Not the others.
Basically, understanding sketchup is not easy. I spend so much time on something, and then I realize it’s not up to me (I guess). For example, right now i figured why I can not make a component to be uniq if the component is in a group that has been copied. When a group copies, it looks like it is not unique. Using count_used_instances I get 2 until I open one of these groups or make an edit. After all day, I realized that I had to make the group unique, so I could do the same with nested components. I do not have enough knowledge to develop extensions, maybe I’m wrong, but the fact is that my script is working now.


Yes this is a little confusing.
The docs say:

Copying a group using the copy tool in SketchUp will create copies of the group that share a common definition until an instance is edited manually or this method is used. If multiple copies are made, all copies share a definition until all copies are edited manually, or all copies have this method used on them. This method ensures that the group uses a unique definition entry in the drawing database.


Thank you! I missed it. I expect that in the near future I will have more time to track documentation, changes in it, etc. I made a stupid omission!


It is well hidden. I think that text bit should be in the description of the class itself, not in the make_unique method description.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.