Moving a surface breaks ObjRef reference?

I’m writing a rhino plugin. The plugin is atempting to keep track of Breps using their ObjRef. The issue is, when a brep is moved, its ObjRef seems to invalidated. Is there any way to keep track of a brep, even after is is moved with the gumball?

More information:
The base ID is not actually changing, it seems like a new revision ID is being created. Why do I think this? When I use the what command on a surface, after the ID is a number in parentheses, this is the number that is changing. It seems like this is a revision number.

If I call RhinoDoc.ActiveDoc.Objects.Hide(ObjRef) after moving the referenced object, nothing happens. It seems like the Reference has died, but it has not. I can still used the ObjRef, but certain things like Hide and Show stop working.

Does anyone know whats going on?

Hi @Nick_Drian,

This is never a good idea, as the Rhino object, referenced by the ObjRef, can be modified. This invalidates whatever ObjRef as referencing.

Under the hood, ObjRef is holding onto a pointer to a Rhino object (C++). Then the Rhino object is modified, a new Rhino object takes it place and the Rhino object is moved onto an undo stack.

Its always best to track objects by their ID, or GUID. You can look up the object based on it’s id as needed.

– Dale

1 Like

Very helpful, thanks!