Hi there,
I’ve been playing around with C# grasshopper components to access the document ObjectTable through rhinocommon. Originally I was looking into how blocks work in Rhino. I noticed that when geometry is ‘converted’ into a block, the original geometry is deleted and copied with a new GUID to the objectTable and referenced by the instancedefinition (block).
This got me wondering what other geometry might be stored in the table, but not “visible”. I noticed that deleted geometry stays on the table until the file is closed, saved and reopened. However, at least from within grasshopper, I’m having difficulty getting a list of the deleted geometry.
For example: I start a new Rhino document and draw three rectangles.
I use the following code to count objects on the geotable:
Rhino.DocObjects.Tables.ObjectTable ot = Rhino.RhinoDoc.ActiveDoc.Objects;
Print(ot.Count.ToString());
foreach (Rhino.DocObjects.RhinoObject objects in ot.GetObjectList(Rhino.DocObjects.ObjectType.AnyObject)) {
Print(objects.ObjectType.ToString());
Print(objects.Id.ToString());
}
and it outputs “3” and “Curve” and the GUID of each curve.
I then delete one of the rectangles, hit F5 and the count still says “3” but the list only shows 2 Curves.
I then use the following, but neither loop returns the deleted geometry:
Rhino.DocObjects.ObjectEnumeratorSettings settings = new Rhino.DocObjects.ObjectEnumeratorSettings();
settings.DeletedObjects = true;
Rhino.DocObjects.RhinoObject[] obj = ot.FindByFilter(settings);
for (int i = 0; i < obj.Length; i++) {
Print(obj[i].Id.ToString());
}
foreach (Rhino.DocObjects.RhinoObject objects in ot.GetObjectList(settings)) {
Print(" " + objects.Id.ToString());
}
Any suggestions?
As a side note, there is a lot of missing documentation on the rhinocommon site, which isn’t making this exploration any easier! Took me a long time to work out the difference between “InstanceDefinitionTable”, “InstanceObject”, “InstanceReference”, "InstanceDefinition, and “InstanceDefinitions” ![:smiley: :smiley:]()
Thanks,
Steven