I am currently trying to solve a problem in one of my Rhino Plugins. I am storing geometry in the User Dictionary of a closed curve. This geometry is automatically generated from the base curve and is being displayed in a custom pipeline
When I drag the closed curve I can subscribe to the RhinoDoc.BeforeTransformObjects event, capture the transform and transform the internal geometry saved in the object which all works very nicely and is just jingles.
However if the user hits undo/redo, I have no way of capturing the inversed transform as the only event I can subscribe to for this is the UndoRedo.UndoRedoChanged Event which does not return the object, let alone the transformation.
Is there a way to capture this missing inverted transform?
Hi @csykes,
As mentioned in this post RhinoCommon - Removing User Data ,when you handle the RhinoDoc.BeforeTransformObjects event, you could do the following.
If you are storing the data in the UserDictionary of the Attributes, then you could first create a copy of the attributes using ObjectsAttribute.Duplicate(). and then transform the internal geometry in the copy. Then apply this copy to your transformed object using ObjectTable.ModifyAttributes() method.
If your user dictionary is attached to Geometry, and not Attributes, then you create copy of the Geometry and then use ObjectTable.Replace()
Hello @Darryl_Menezes, I can handle that event perfectly, that’s relatively simple. What I can’t do is handle the reversing of this event when a user uses the Undo or Redo commands.
If you are attaching or modifying a user dictionary from a RhinoDoc.BeforeTransformObjects, then the modifications to you dictionary will not be undo-able.
Thank you for this sample, I shall take a look. I didn’t think the UserDictionary would be undoable, but I wondered if the inverse transform would be captured in the Undo.
I have come up with a solution that fits my issue. Since it’s all based on curves, when Undo is called, ReplaceRhinoObject is also called. If Redo/Undo is active I can then grab the old curve and the new curve, calculate the transform between them and send that as a custom event to my code. This works quite nicely and handles this edgecase . Thank you for your help! And your Code has given me quite a few other ideas for other issues I was having .