Object change tracking and rebuild case

How i can know when existing object will lose current id - i mean i have issue when after rebuild command i cannot track further object because it has changed id. Any remedy @dale ?

Hi @D-W,

An object’s uuid should not change after Rebuild. However, it’s object runtime serial number will.

Does this help?

– Dale

I know that cause im checking if serial number changed. Ahh… stupid mistake i haven’t unsubscribed event handler from a deleted object and i’m getting null… My fault.

Hmm… so when do i know when actually object is deleted? Each time when object is changed rhino doc deletes it and adds it again. How do i check if i can dispose my object which is tracking rhino object?

When Rhino.RhinoDoc.DeleteRhinoObject is called i can check if storedId == e.ObjectId and if storedSerial == e.TheObject.RuntimeSerialNumber which are both correct since new serial number is set when object is added to doc again. As usual i’m missing something here…

@dale do i have to store also bool from ReplaceRhinoObject if object will be replaced?

Side question: @stevebaer Is this class interop ? I wonder if i could pass data to other c++ plugin using this class.
https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_DocObjects_Tables_RuntimeDocumentDataTable.htm

@dale is this poper way of tracking definetly deleted object?

Hi @D-W,

When tracking Rhino objects, you should always do so using the object’s id, or uuid.

When a Rhino object is deleted, a RhinoDoc.DeleteRhinoObject event will be trigger.

Now, this event will also be triggered when an object is replaced, which triggers a RhinoDoc.ReplaceRhinoObject event. Please read the help carefully on how this event works.

– Dale

Thanks @dale for pointing out method description and sorry for being lame but its kinda unnatural in my understanding to delete and add object each time it moves for eg. - but i will get used to it :wink:

I taged Steve due to side question however i found your mosse example for interop things but first of all i was wondering if there is any option to pass custom/user object from c# to c++ plugin internaly in rhino without additional libraries?

Hi @D-W,

Keep in mind that modifications to Rhino objects are undo-able. In this case, the old object is moved to the undo stack (deleted) and the new copy added to the document.

In regards to .NET Interop and passing .NET objects to C++, we’ll probably need more information on what you are trying to do. The more typical scenario is to use C++ classes and functions in .NET, not the other way around.

– Dale

You’re right! Thanks again for pointing this out since i don’t use undo/redo i completely forgot about those. That clarifies my thoughts :slight_smile:

I’ve added you to PM ( which i know you don’t like :wink: ) with Steve i described there in depth whats and whys.