Mesh not accessible after creation with InstanceObject.CreateMeshes()

I want to create the meshes of user-selected InstanceObjects to perform Boolean operations with them afterwards. Neither in the editor GUI nor in the code I succeeded so far for the attached file twoBoxes_blocks.3dm (42.4 KB).

However, when I don’t create block definitions twoBoxes.3dm (45.6 KB), it works in the GUI. But in my case I need it to function with block definitions.

code:

/// C#
Rhino.DocObjects.ObjRef[] selection;
var rc = Rhino.Input.RhinoGet.GetMultipleObjects("message", false, ObjectType.InstanceReference, out selection);
var part1 = selection[0];
var part2 = selection[1];
part1.(MeshType.Analysis, new MeshingParameters(), false);
part2.(MeshType.Analysis, new MeshingParameters(), false);
var m1 = part1.Object().GetMeshes(AnalysisMesh);  // returns Rhino.Geometry.Mesh[0]
var m2 = part2.Object().GetMeshes(AnalysisMesh);  // returns Rhino.Geometry.Mesh[0]
var splits = Mesh.CreateBooleanSplit(m1, m2);        // returns null

As an alternative to GetMeshes() I tried without success also:

part1.Mesh(); // returns null

However, there has to be a mesh because

 part1.Object().MeshCount(MeshType.Analysis, new MeshingParameters());  // returns 1

How can I access the meshes and perform the boolean operation?
System: Rhino for Mac 5.2.2

Hello,
Try use InstanceObject class and InstanceDefinition property.

instanceobj = part1.Object() as InstanceObject;
instanceobj.InstanceDefinition.GetObjects();

Example: http://developer.rhino3d.com/api/RhinoCommonWin/html/P_Rhino_DocObjects_InstanceObject_InstanceDefinition.htm

1 Like

thanks! for creating or only for accessing the meshes?

InstanceDefinition.GetObjects() return array of the RhinoObject that belong to block. Simply you must iterate on the objects and call GetMeshes member or if meshes not created for object you must call CreateMeshes memeber to create specific mesh for render, analysis etc.

1 Like

You will also need to apply the InstanceObject’s transform to the mesh, otherwise it will end up in the incorrect location.

– Dale

1 Like