nathanletwory
(Nathan 'jesterKing' Letwory)
February 7, 2019, 3:38pm
7
@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.
// now we get an instance. It tells you its identifier InstanceId, the mesh UUID that is connected with this
// the mesh index and the transform for this instance. Additionally you'll find the MaterialId for this instance.
// Also for non-blockinstance objects you'll get here. There'll be then just one mesh instance using a MeshId. In that
// case the transform is identity, since Rhino mesh data is always in world, except for block instances.
// realization of a mesh(part) in the world
ON__UINT32 iid = instance->InstanceId();
ON_UUID mid = instance->MeshId();
int meshindex = instance->MeshIndex();
ON_Xform xform = instance->InstanceXform();
ON_3dPoint p = ON_3dPoint::Origin;
ON_3dVector zup = ON_3dVector::ZAxis;
p.Transform(xform);
zup.Transform(xform);
// the material ID can be used to query the actual material from the ChangeQueue. In Rhino you can have the situation where
// the same mesh has different materials. This happens especially with block instances. To illustrate: In Rhino add a _Box.
// Set the box material to "Use Object Parent". Now create a _Block out of the box. Duplicate the instance that is placed in
// the location of the box. Add two materials to the material editor and assign each block instance one.
// It is here that you'll get for the same mesh (MeshId + MeshIndex) a different MaterialId.
int materialId = instance->MaterialId();
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)
1 Like