If I have a mesh, how do I find out to which block instance it belongs? Is it possible?

Hi !

So, I am in the process of making an exporter plugin for Rhino to some other format using the C++ API, and have now been facing the issue of correctly exporting the Block instance objects.

Currently I am first maintaining an array of meshes, by using the RhinoMeshObjects() function, that saves the meshes into an array called allMeshes.

So, my main concern here is how would I find out if a mesh in the allMeshes belongs to a block instance object, so I can manipulate the mesh’s vertices with the transform of the block object.

How can I achieve that?

If you are working on an exporter for v6 and are interested primarily in mesh geometry from objects you should look into using the RhRdk::Realtime::ChangeQueue to get out mesh data and with that useful identifiers for mapping between objects and mesh instances - this will take into account block instances.

When you get a mesh ID that is used in multiple instances you’ll be able to see that.


Although the ChangeQueue was initially conceived for integration with the display system it works perfectly for exporter scenarios as well.

You essentially will derive from RhRdk::Realtime::ChangeQueue, instantiate one with the doc you want to export, call CreateWorld and Flush. With the correct Apply* functions implemented you’ll get all geometry preprocessed, including all blocks, nested and what not, materials etc.

If this sounds like something you’d be able to use I can type more text to clarify how to do that

1 Like

Hey @nathanletwory, RhRdk::Realtime::ChangeQueue does sound like a viable solution to my problems . But, my code is almost complete and I do not think that I could afford the time to change the RhinoMeshObjects() way I am using right now.
Nevertheless, I would like to know more about RhRdk::Realtime::ChangeQueue to work on it in the future. Thanks!

@alexian007 I’m not pretending I know how you have set up your code, but I’m pretty sure a move to the ChangeQueue won’t be that big a change. Anyway, let me type on a simple sample code to show you how it can be used.

1 Like

Oh, okay then. So will implementing the ChangeQueue give me an easy way to :

a) Access an individual mesh i.e a CRhinoMeshObject or something similar, to get the mesh data, attributes.
b) Find out if the mesh is a part of the instance or not.
c) Easily map the mesh and the object/ block instance it belongs to?

I will be able to do all these, right? If so, I will gladly make the change to ChangeQueue.

So, the basic overview of my project is that I use RhinoMeshObjects() to get an array of CRhinoMeshObject meshes.

Then, I use the objectIterator to get all the objects on the document and store it in another array.

And, then I iterate the object array to search the mesh array according the id and then assign the mesh to the object.

(I do so because I am making another object definition for the software I am exporting to, so I am transferring the data of a Rhino object to another data container that contains all its data and the references to the mesh too from the mesh array I obtained earlier.)

So, what I am doing to associate the mesh to the object is by:

if (allMeshes[i].m_parent_object->Attributes().m_uuid == currentObjID)

allMeshes = the meshes array obtained from RhinoMeshObjects()
currentObjID = the ID of the current object I got by iterating the object array obtained from objectIterator.

So, if implementing a ChangeQueue will give me better organisation and won’t be much time consuming, I would really love to know that, Nathan.

Thank you, and I am awaiting for the sample code! :slight_smile:

So, a few moments of typing and a basis for creating an exporter on top of the all-new RhRdk::Realtime::ChangeQueue is now ready at

I’ve tried to document the Apply* functions heavily with how the process works. If you still have questions then obviously feel free to ask them here! I can improve the sample until there is no more doubt about its mechanisms :slight_smile:


Yaay! Give me some time to look through it, and I’ll shoot all my questions here.
P.S: You ROCK, Nathan ! :smiley:

If you want to see the ChangeQueue in action here is the Raytraced code using it in C# (C# is a wrapper around the C++ code, more or less functioning the same way):

1 Like

Btw, I attached a pre-compiled RHP of the sample here:

1 Like

Yeah, I got it thanks! I am still in the process of understanding the changequeue, and seeing it in action is awesome !

Ask when there is anything that is unclear.