A very basic implementation of baking and deleting objects in Rhino through Grasshopper.
Rhino ObjectTable
Rhino objects are accessed through the object table – a container object which holds information about all objects in a Rhino document.
Rhino.DocObjects.Tables.ObjectTable ot = Rhino.RhinoDoc.ActiveDoc.Objects;
Add an object
Within the ObjectTable is a range of methods for adding objects. There is a method for each kind of geometry (meshes, lines, points and so on).
For example, to add a line:
ot.AddLine(new Point3d(0, 0, 0), new Point3d(1, 1, 1));
Deleting the most recent object
The Object Table appears to be sorted in order that objects were added, most recent first. So, to delete the most recent object, we need to delete object 0:
//get guid of the most recent object Guid id = ot.ElementAt(0).Id; //deletes this object if(z) ot.Delete(id, true);
Get the number of objects
Unless there’s a better way to do it, the method below works. This returns the number of objects in the object table.
var sf = new Rhino.DocObjects.ObjectEnumeratorSettings(); int count = ot.ObjectCount(sf);
Hi James,
Thank you for your post!
Could you please take a look at my problem here:
http://www.grasshopper3d.com/forum/topics/save-internalized-grasshopper-geomerty-while-preserving-the-tree
I really need your advice on that.
Best,
Yijiang