Hello newb question here. I’m not sure where to look in the API for this but I’m would like to get the name of each object and add it to my list. I’m not sure what Class or method gets the names of objects?
You should specify which language you want to see an example in.
Sorry for some reason I thought I added it in the tags. C#
https://developer.rhino3d.com/api/RhinoCommon/html/P_Rhino_DocObjects_ObjectAttributes_Name.htm
You would refer to the name via RhinoObject.Attributes.Name
If backing out from the above page following the “path”, or object structure, you would find the following pages:
- https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_DocObjects_ObjectAttributes.htm
- https://developer.rhino3d.com/api/RhinoCommon/html/P_Rhino_DocObjects_RhinoObject_Attributes.htm
- https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_DocObjects_RhinoObject.htm
In short: RhinoObject.Attributes.Name
And, the different ways to obtain an (Rhino) object reference in the first place, can be found in the follwoing namespace:
- Rhino.DocObjects.Tables - https://developer.rhino3d.com/api/RhinoCommon/html/N_Rhino_DocObjects_Tables.htm
// Rolf
So this is my attempt to get the name attribute in a list but I’m getting a null error in the foreach each in rhinoObjects?
private ObjectTable rhinoObjects;
private System.Windows.Forms.ListBox listbox1;
private void InitializeComponent()
{
this.listbox1 = new System.Windows.Forms.ListBox();
// List of Objects
this.listbox1.Click += new System.EventHandler(this.ObjectList_SelectedIndexChanged);
this.listbox1.Name = "Outliner";
this.listbox1.Size = new System.Drawing.Size(94, 23);
foreach (RhinoObject o_ref in rhinoObjects)
{
RhinoObject obj = o_ref;
string curvename = obj.Attributes.Name;
this.listbox1.Items.Add(curvename);
this.listbox1.Text = curvename;
}
}
Because your rhinoObjects property is not initalized and therefor empty.
You need the doc from the rhino command and assing doc.Objects to rhinoObjects or just foreach-loop over doc.Objects.