Add object with custom guid: possible?

How to add a new object with custom guid?


Use ObjectTable.AddRhinoObject Method to add your object. So create the actual object, set its RhinoObject.Id Property to an ID that hasn’t been used yet. See the documentation of the Id property:

Every object has a Guid (globally unique identifier, also known as UUID, or universally unique identifier). The default value is Guid.Empty.

When an object is added to a model, the value is checked. If the value is Guid.Empty, a new Guid is created. If the value is not null but it is already used by another object in the model, a new Guid is created. If the value is not Guid.Empty and it is not used by another object in the model, then that value persists. When an object is updated, by a move for example, the value of ObjectId persists.

This value is the same as the one returned by this.Attributes.ObjectId.

1 Like

That is not the recommended approach in RhinoCommon as you typically can’t directly create RhinoObject instances. Use the Add functions that take an ObjectAttributes as input. Create an instance of ObjectAttributes and set it’s ObjectId property to the Guid you want to use.


Thank you @nathanletwory and @stevebaer
I tried to assign a custom guid to ClippingPlane but than i find another way to keep the last one using FindClippingPlanesForViewport and Delete