I feel like this is an immensely stupid question, but I’m simply not able to get it done. I need to delete an object from the scene, and Rhino.RhinoDoc.ActiveDoc.Objects.Delete only accepts a GUID, not a RhinoCommon object. However, I simply cannot find anywhere how I am supposed to obtain the GUID from a RhinoCommon object. It has to be incredibly easy, but I simply can’t get it done.
If you have a grip on a Rhino object, have you tried to read the Id property?
https://developer.rhino3d.com/api/RhinoCommon/html/P_Rhino_DocObjects_RhinoObject_Id.htm
// Rolf
How exactly would I grip my object?
Rhino.DocObjects.GripObject(curve) Doesn’t work
Ah I get it now! I made a mistake in my variable assignments, which meant that a not-yet-made RhinoCommon object shared it’s variable name with a GUID object in the scene. This is the reason I wasn’t able to remove it and also why it gave me the RhinoObject not a GUID error. Your link gave me the insight I needed, because it told me that object obtain a guid once added to the scene. Which is incredibly obvious, because it wouldn’t be a GUID if it wasn’t visible in the GUI
I’m still new to this
The following example should help you out when you don’t have a reference to the object yet:
The samples pages is gold
// Rolf
I’ll make sure to add this to my reference, I’ve mostly been searching both API’s
Yep, as you found out, you don’t actually need to delete anything that has not been added to the document, as it is just a virtual construction in memory. If you don’t do anything with it, the memory it takes up is simply reclaimed by the “garbage collector” after the script ends.
I’ve got somehow similar problem.
I used GetObject.GetMultiple() to get a list of references to curves in my document.
Now i’m iterating through this list and I would like to get GUID of my curves. I thougt that i will have an acces to ID property by I don’t.
If i have Rhino.Geometry.Curve object that already exist in the document how to access it GUID ?
Hi @kubadrozdowski,
Curve do not have ids, or GUIDS. If you need the ids, then maintain a list of Rhino objects.
var CurveObjectList = new List<CurveObject>();
foreach (ObjRef objref in gc.Objects())
{
if (objref.Object() is CurveObject obj)
CurveObjectList.Add(obj);
}
– Dale
Thank you @dale