Immutability of RhinoObject

Hi everyone,

I have a wondering that can be possibly effect my point of view to develop my plugin classes. This wondering appeared when I see arguments of ReplaceRhinoObject event handler which are e.NewRhinoObject, e.OldRhinoObject and e.ObjectId.

Question: When something replaced, is RhinoObject duplicates itself as immutable object or changes only geometry in it as mutable object? I confused because of e.NewRhinoObject and e.OldRhinoObject shares same Guid but their geometry is different. How their states change, when something replaced?

Thanks,
-Oğuzhan

Hi @oguzhankoral,

Keep in mind that a RhinoObject is comprised of two members: a GeometryBase inherited object, and an ObjectAttributes object, which stores the Rhino object’s Guid and other attributes (e.g. layer, material, etc.).

When you call one of the many ObjectTable.Replace overrides, Rhino creates a new RhinoObject that includes the input geometry and a copy of the source object’s ObjectAttributes member. This is why the Guid of the “old” and “new” objects match.

After Rhino fires a RhinoDoc.ReplaceRhinoObject event, it moves the “old” RhinoObject onto it’s undo stack. It then updates the runtime serial number of the “new” RhinoObject and adds it to the object table.

Does this help?

– Dale

1 Like

Hi @dale,

Your answer clarified my question, thanks. I am still trying to handle same issue which is related to undo/redo, this question was originated from there. I was trying to understand states of RhinoObjects to find an idea about it.

-Oğuzhan