How exactly do I get the position of a block instance object, which doesn’t contain any geometry in itself and holds other sub-objects ?
The block instance is represented by the CRhinoInstanceObject.
With the method InstanceXform() you get the transformation of this block.
Hi @dsw, nice to see you here
Thanks for your quick reply!
ON_Xform object that I get from the
InstanceXform(), has various methods regarding the object’s transformation.
What I need is just X, Y, Z axes information of the object.
Translation() method the way to go? I will be checking it out, but it would help me to save time if you knew the exact way to get the data I want.
CRhinoInstanceObject object, you can calculate it’s insertion point like this:
const CRhinoInstanceObject* iref_object = ... ON_3dPoint point = ON_3dPoint::Origin; point.Transform(iref_object->InstanceXform()); // TODO: do something with point.
Thanks @dale, that helps, but it is still not giving me the results that I want
The point will contain the location of the instance - the translation.
Ah, but you probably also want the rotation I guess so that you can create the axis info.
@alexian007, I have updated the changequeue sample to use the ON_3dPoint method shown by @dale to get the position. I also do something similar with the z-axis. This gives you a new z-axis for the block instance.
A few lines down there I also print the entire transform.
You can use the sample with the attached RHP and 3DM for testing
SampleRdkChangeQueue.rhp (166.5 KB, built against 6SRC13, can rebuild if needed).
SampleRdkChangeQueue.rhp (169 KB, compiled against 6SR0).
SampleRdkChangeQueue.3dm (32.5 KB)
If I have a mesh, how do I find out to which block instance it belongs? Is it possible?
Before we throw out any more speculation, perhaps you can explain what this means to you? What problem are you trying to solve?
Hey @dale, the situation I am having is:
- Export the mesh of an object into another file format, for another 3d software.
- When I export a normal object, it works fine.
- But, when exporting block objects, the duplicated block objects appear on the same location as the original.
- So I am trying to modify the mesh’s vertices to get the correct position.
To show you, this is the model in Rhino. (The highlighted section is of all block instances. Some are unique while others are duplicates of one another) :
And, the result after exporting it is this:
What is happening here is that all the duplicated block instances all appear on top of one another, I have marked a section as 1 to show you that 2 was underneath it. Basically, it is taking up the same location as the original block object’s position.
So, this was why I wanted to apply the block instance position to the mesh.
So any thoughts you have regarding this?
Does this mean the viewer you are using does not have the concept of mesh instancing?