I have a problem with my plugin and Undo operations. I have a set of custom classes which store collections of Sketchup entities. These all react to observer events of various kinds.
I have discovered that when a user hits “undo”, the references I have in my custom classes to these entities become Deleted Entity references.
Try this for yourself in the Ruby console:
- create a rectangle, and select the face, type
temp_face = Sketchup.active_model.selectioninto the console
- move one of the edges of the face. You will find that typing
puts temp_faceinto the console will refer to the same face.
- now hit “Undo” form the Edit menu.
- type in
puts temp_faceto the console again, and you will find that it refers now to a Deleted Entity.
- Try “Redo” and you will find that the
temp_facestill refers to a Deleted Entity.
All this makes it very difficult for me to track entities (which I observe with various observers) across the undo stack. In fact when the user clicks “Undo”, pretty much my whole custom entities structure gets broken.
Is there anything I can do to continue to track entities across Undo commands, or do I have to rebuild my custom classes (and observers) on every Undo (and Redo) operation? Sounds expensive to me.