I’m trying to save Blocks and BlocksInstances from a .NET application. I’ve managed to add my InstanceDefinitionGeometry in the File.AllInstanceDefinitions collection. But now I would like to save the actual instances. With most object types there’s a dedicated File3dm.Objects.AddXXX, but I don’t see one for InstanceReferenceGeometry. Perhaps i’m not looking at the right place?

I’m using the latest prerelease Rhino3dmIO.Desktop version 7.0.18072.3575-wip
Thanks for your help.

(Dale Fugier) #2

Hi @AlexM,

An instance definition geometry object is one whose ObjectAttributes.Mode property is set to ObjectMode.InstanceDefinitionObject.

Does this help?

– Dale


I mean not the InstanceDefinitionGeometry with actual geometry. But the actual instance. Which generally is only a transformation. I think you call them InstanceReferenceGeometry.


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)

(Dale Fugier) #5

Hi @AlexM,

Does the File3dmObjectTable.Add method work for you?

– Dale


Unfortunately no. The File3dmObjectTable.Add method only takes a File3dmObject as parameter. The only File3dmObject constructor supports a Guid and another File3dm and it’s attributes and geometry are read-only. I’m guessing it is for external block references.

Any other things I could try?

Thanks for your help.


(Dale Fugier) #7

Hi @AlexM,

I’ll see if I can get something added for a service release that will help.

– Dale


Hi Dale,

Thanks this is much appreciated. I see on YT the release target is 6.5. Any idea when this is supposed to be released? Q2-2018 for example.


(Dale Fugier) #9

Hi @AlexM,

I’ve been on about a monthly cycle with Rhino 6 service releases. So you should see an SR 5 release candidate available round the first of May.

– Dale


Perfect. Thanks for the quick implementation. I’ll post back here when I’ve tested it.

I remember fondly the good old V2 Beta days, when you would release vbscript methods on a daily and sometime even hourly cycle :smiley: