HI every one
First of all I’m New to Rhino development.
so I was wondering how can I add a new Sub Object of any type to an existing instance object? I’m using rhino7 and c#.
Hi @arc.feizbahr ,
you could use the InstanceDefinitionTable.ModifyGeometry() method to update the geometry of the existing InstanceDefinition
Something like this
public static bool AddToInstanceDefinition(InstanceDefinition instanceDefinition, RhinoObject rhinoObject)
{
RhinoObject[] subObjects = instanceDefinition.GetObjects();
List<GeometryBase> geometryList = subObjects.Select(x => x.Geometry).ToList();
List<ObjectAttributes> attributesList = subObjects.Select(x => x.Attributes).ToList();
geometryList.Add(rhinoObject.Geometry);
attributesList.Add(rhinoObject.Attributes.Duplicate());
return RhinoDoc.ActiveDoc.InstanceDefinitions.ModifyGeometry(instanceDefinition.Index, geometryList, attributesList);
}
1 Like
Thanks @Darryl_Menezes
It works perfectly,
Thanks a lot…