I have an array of meshes that I iterate through. If the mesh doesn’t match certain criteria I want to move it to another layer. I am struggling to work out how to get the Object/ObjRef or Guid for the mesh in order to change its layer
Mesh[] _meshes; //assigned by user selection
layer_index = 2;//unmatched layer
for (int meshNumber = 0; meshNumber < _meshes.Length; meshNumber++)
{
...
//if certain criteria aren't matched
//get Guid/Objref or Object for the mesh (this is the thing I can't do) - then
Rhino.DocObjects.ObjRef oRef = new Rhino.DocObjects.ObjRef(guid);
Rhino.DocObjects.RhinoObject rhobj = oRef.Object();
rhobj.Attributes.LayerIndex = layer_index;
rhobj.CommitChanges();
}
But - I then go through and do some processing and drop some of the meshes the user selected - which is why it’s now an array of Mesh rather than a GetObject. I could go back and change lots of code to store the ObjRef but I just wondered if that’s necessary.
Uhm… You can make a second array where you store the ID’s.
And add a little code in between where when you remove a mesh you also remove the ID from the array. That way you dont have to change your code but only add a bit.
Second way is to loop through all objects. compare the mesh in the array with the meshes in the drawing and if its a hit use that mesh but this can consume a lot of time if its a big drawing.