I want to import blocks from a file into the file. However, the nested blocks are not added to the InstanceDefinitionTable
. I checked the data, and the nested blocks are imported as InstanceReferenceGeometry
, but they are not added to the InstanceDefinitionTable
.
string filePath = string.Empty;
if (!DA.GetData(0, ref filePath)) return;
File3dm file3dm = File3dm.Read(filePath);
RhinoDoc doc = RhinoDoc.ActiveDoc;
List<string> stringGeomatry = new List<string>();
foreach (var instanceDef in file3dm.InstanceDefinitions)
{
List<GeometryBase> blockList = new List<GeometryBase>();
List<ObjectAttributes> blocattribute = new List<ObjectAttributes>();
foreach (var obj in instanceDef.GetObjectIds())
{
var taype = file3dm.Objects.FindId(obj);
blockList.Add(taype.Geometry);
blocattribute.Add(taype.Attributes);
}
doc.InstanceDefinitions.Add(instanceDef.Name, instanceDef.Description, Point3d.Origin, blockList,blocattribute);
}