Here’s some additional information to better describe my problem. Please see attached 3dm file created with Rhino 5. It contains 1 block (a square polyline) and 4 instances.
When reading the file, I can iterate the File3dm.AllInstanceDefinitions.GetObjectIds to get the guids of the geometry defining the block. Then I retrieve the objects from the File3dm.Objects by checking the File3dm.File3dmObjects.Attributes.ObjectId. With the attached sample file, it would retrieve only one Polyline.
Now I have my Block defined, I need the instances. I can iterate File3dm.File3dmObjects and get the InstanceReferenceGeometry objects which are basically a transformation and a parent guid pointing to the InstanceDefinitionGeometry.
I can successfully read blocks and instances from the 3dm files. Now my problem, is when I want to save them.
Saving the definitions:
I can create InstanceDefinitionGeometry (specifying name) and add them to the File3dm.AllInstancesDefinitions collection, retrieve their guid (I’d be great if the Add method would return the guid of the newly added def). Now somehow, I need to add the geometry defining the block in the File3dm.File3dmObjects collection and provide the parent InstanceDefinitionGeometry id. I thought perhaps there was a ObjectAttributes subclass, but couldn’t find any. How should I add the geometry defining a block to the File3dmObjects collection?
Saving the instances:
With all other object types there is a file3dm.Objects.AddXXX(geometryBase, attributes). I can create my geometryBase like this: new InstanceRefenceGeometry(parentGuid, transformation), I also have the attributes… I just don’t see a method to add them to the file3dm.Objects collection. Any clue?
ThanksBlocks.3dm (15.5 KB)