Trouble in transforming InstanceObjects

Hi all,

I’m trying to transform InstanceObject(s) through RhinoCommon but having troubles about it. When I transform its geometry using the Transform() it returns true and the InstanceReferenceGeometry's Xform is modified correctly however I then have to use CommitChanges() to reflect the changes to the document but it fails and returns false.

There is a way-around using ObjectTable.Transform() but it simply adds a new object and deletes the old one, if specified. This complicates the things for me since it actually adds a new RhinoObject with a new Guid, while the plugin I’m developing has a custom event handler for Add event, which is not working well in this situation.

So my question is, is there a way to transform the InstanceObject while keeping its Guid intact or do I have to accept the only way to transform it is through adding a new object and adapt my code around it?

Hi @Serdar,

Calling ObjectTable.Transform and passing True for deleteOriginal will replace the object’s geometry with the new, transformed geometry and, thus, leave the object’s ID intact.

Simple test:

import Rhino
import scriptcontext as sc

def test():
    filter = Rhino.DocObjects.ObjectType.InstanceReference
    rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select block instance to move", False, filter)
    if not objref or rc != Rhino.Commands.Result.Success:
    rh_obj = objref.Object()
    if not rh_obj:
    id = rh_obj.Id
    print("Id: {0}".format(id))
    for i in range(0, 10):
        dir = Rhino.Geometry.Vector3d.XAxis
        xform = Rhino.Geometry.Transform.Translation(dir)
        sc.doc.Objects.Transform(rh_obj, xform, True)
        rh_obj = sc.doc.Objects.FindId(id)
        if rh_obj:
            print("Id: {0}".format(rh_obj.Id))

if __name__ == "__main__":

– Dale