Hello,
I need to transform InstanceObject
s. I can do this with
ObjectTable.Transform(obj, xForm, deleteOriginal: true)
, see ObjectTable.Transform Method (RhinoObject, Transform, Boolean)
But that doesn’t work if the InstanceObject
is part of another InstanceDefinition
(obj.IsInstanceDefinitionGeometry
is true).
The only way to transform such an InstanceObject
, that I’ve found is the InstanceDefinitionTable.ModifyGeometry
method, see InstanceDefinitionTable.ModifyGeometry Method (Int32, IEnumerable(GeometryBase), IEnumerable(ObjectAttributes))
var oldObjects = definition.GetObjects();
var geometries = oldObjects.Select(x => x.Geometry);
var attributes = oldObjects.Select(x => x.Attributes);
// replace the object to transform with a new InstanceReferenceGeometry with new transform
InstanceDefinitionTable.ModifyGeometry(definition.Index, geometries, attributes);
This does work, but it changes the Id
of all objects belonging to the InstanceDefinition
. When using the BlockEdit
command manually, the Id
s stay the same. I’d really love to not change all those Id
s. What can I do to keep the Id
s? Are there totally different ways to transform a nested InstanceObject
that I haven’t thought about yet?
Thanks for helping out,
Simon