Hello.
I’ve been struggling all day long with this issue.
I need to get the list of vertices from each object I import in my scene as a .step or .3dm file.
Eventually, the goal is to compare the model I import with a set of models to find which one it matches.
Elefront lets me do that by exploding the block and analysing the Brep, but I need to automize with a C# script so that as soon as I import a file, the matching gets done.
I’ve tried this :
By adapting it in C#, I got this :
List<GeometryBase> GeoOutput = new List<GeometryBase>();
List<Rhino.DocObjects.RhinoObject> BlockInstanceList = new List<Rhino.DocObjects.RhinoObject>();
BlockInstanceList = Rhino.RhinoDoc.ActiveDoc.Objects.FindByObjectType(ObjectType.InstanceReference).ToList();
Rhino.DocObjects.Tables.InstanceDefinitionTable BlockDefinitionList = Rhino.RhinoDoc.ActiveDoc.InstanceDefinitions;
for(int i = 0; i < BlockDefinitionList.Count(); i++)
{
List<Rhino.DocObjects.RhinoObject> BlockObjects = new List<Rhino.DocObjects.RhinoObject>();
BlockObjects = BlockDefinitionList[i].GetObjects().ToList();
for(int j = 0; j < BlockInstanceList.Count(); j++)
{
//Rhino.DocObjects.RhinoObject Block = BlockInstanceList[j];
Rhino.DocObjects.InstanceObject Block = BlockInstanceList[j];
Transform XForm = Block.InstanceXForm;
for(int k = 0; k < BlockObjects.Count(); k++)
{
GeometryBase objX = BlockObjects[k].DuplicateGeometry();
objX.Transform(XForm);
GeoOutput.Add(objX);
}
}
}
But I get the following error message :
Am I missing something?
How can I convert a RhinoObject into an InstanceObject so that I can use InstanceXForm?
Thanks for your feedback!