How to add a modified object and maintain the same ID? C++

Hello everyone,

I am trying to add to scene of Rhino a modified curve that maintains the same ID from the original one.

I explain the scenario:

The user have to select a set of object, that might be curves, surfaces and points. Then the command will do a set of operation on those object and when the command is finished I add those object on the scene.

I pick the objects by using the CRhinoGetObject class.

After that I retrieve the CRhinoObjRef and then the geometries of the selected objects and cast them to ON_Curve, ON_Surface and ON_Point.
After I have the geometries I modify them.

How can I modify the original objects with the data that I have with the modified object? In clearly, I need that the object that I have selected become the modified one preserving all of its attributes (ID, color, layer, etc. )

They way you do this is:

1.) Get the object
2.) Make a copy of the object
3.) Replace the original object with the modified copy using CRhinoDoc::ReplaceObject

This sample project contains many examples of this.

– Dale

1 Like

Hi Dale,

How is it possible in vb? i mean replacing object without changing ID.
I tried doc.objects.replace() but id changed.


That shouldn’t be happening. Do you have some code that exhibits this behavior?

Yes you are right, now it works. i realized i made a mistake.