How to copy the transformation of one InstanceObject to another one

Hello,

in Rhino 8 and RhinoCommon I would like to copy and apply the transformation of one Rhino.DocObjects.InstanceObject (instanceObjA) to another one (instanceObjB). Both instance objects consist of multiple mesh objects.

I tried it this way and it has no effect on instanceObjB:

instanceObjB.Geometry.Transform(instanceObjA.InstanceXform);
instanceObjB.CommitChanges();

I also tried to iterate through all instanceObjB.GetSubObjects() and applied instanceObjA.InstanceXform to those objects without success.

I further tried to iterate through all instanceObjB.GetMeshes(Rhino.Geometry.MeshType.Any) and applied instanceObjA.InstanceXform to those objects as well. No success.

How can I apply the transformation of one Rhino.DocObjects.InstanceObject to another one?

Best regards
Timothy

Find the correct transformation from the current Xform to the target Xform, then use the
RhinoDocument.Objects.Transform method.

1 Like

That method did the trick.
Thanks Riccardo!