Exporting Multiple Block Definitions

Is it possible to export multiple block definitions at once in Rhinocommon? Just like it is done in block manager as shown in below picture

I have tried this using RhinoApp.RunScript(), but then I can only export one block at a time, and have to repeatedly provide block names as seen below


This works, but is relatively slow compared to the first approach.

Hi @Darryl_Menezes,

There is no equivalent function in RhinoCommon. You can always write your own files with with File3dm, but its a fair amount of work.

– Dale

Hi @Dale,
Thanks for your response. I am currently writing files with File3dm. The only thing I am not able to do is Create ‘Linked and Embedded’ InstanceDefinitionGeometry. There is a method called File3dmInstanceDefinitionTable.AddLinked() which adds ‘Linked’ definitions but not ‘Linked and Embedded’ definitions. Would there be such an option in future? Thanks.

You don’t create special linked geometry. Linking simply occurs when inserting a file as a block.

Or am I confused what you want?

– Dale

I am trying to export a block from a Rhino file, by creating a new File3dm object.
I am using InstanceDefinition.GetObjects(), and looping through all the RhinoObjects and adding their geometry to the File3dmObjectTable.
But my InstanceDefinition also contains nested blocks inside it which are ‘Linked and Embedded’.
For this, I have to first create InstanceDefinitionGeometry.
But as of now, there are two functions,

  1. File3dm.AllInstanceDefinitions.Add() which adds embedded InstanceDefinitionGeometry
    2)File3dm.AllInstanceDefinitions.AddLinked() which adds linked InstanceDefinitionGeometry
    But there is no function which lets me add ‘Linked and Embedded’ InstanceDefinitionGeometry to the File3dmInstanceDefinitionTable.

Hi @Darryl_Menezes,

Sorry for the delay in replying. I don’t have a good answer for you right now, at least using RhinoCommon.

– Dale

@dale as i understand there’s no other way than scripting to get import/export block functionality? Only handling on own read/write File3dm will do the work? No shortcuts?

I’m digging whole morning to find a way to export individual block and import 3dm file as embedded and linked block directly from code.

Even via script i noticed different behavior in v5 and v6 - v5 on double import of the same file in a row keeps block name the same - v6 changes definition adding uuid/guid to its name?

Besides after deleting linked block if there is a block in it will stay there no matter if i delete it or even purge whole file referenced block seems to be “stuck” if done multiple times v5 dobules them with XX ( where X is an appropriate number) “postfix” while v6 seems not doing this. I’m wondering how uuid/guid of instance def behaves when saved and reopened is it reliable value to work with when we talk about linked blocks?

Also no opt to reexport already linked block via BlockManager scripting (even not working in modal) - i guess only copy approach will work here deciding using - InstanceDefinitionUpdateType - but how do i track path of original archive - is it SourceArchive ?

Next weird thing in v6 is this:
Compact doesn’t make a difference here + Purge hides this temporarly then - boom again big list:

Besides deleted linked blocks with reference layers leave “unactive” mess in layer manager and can’t be deleted at all. Seems like the block management system has “holes larger than a Swiss cheese”.

Hi @D-W,

If the question is whether or not there are functional equivalents to _-Insert _File=_Yes or "_-BlockManager _Export`, then no, I don’t believe there is. I’ve created a YouTrack issue to confirm or deny my statement and to provide such a way if needed.


There is a substantial amount of work behind each.

Yes, this is true. Before inserting from file as embedded with link, verity the block doesn’t already exist. If it does, just insert it as you would any other block defined in the model.

Sounds like a bug. Can you provide step-by-step instructions on how to reproduce this?

True. This is because the linked block it not defined in the current model. Basically, it’s already exported if that makes sense.

I’m not following your comments - sorry. Please provice me steps to reproduce.


– Dale

Sure. Insert 3dm model which contains a block definition as a linked block - in Block Manager show referenced blocks then delete the 3dm inserted block from document and ofc Block Manager and you will end with “stucked” reference model.

The same thing happens for layers when the link is in the reference mode layer is “stuck” and can’t be deleted.

It makes sense - at least I guess so :slight_smile:

After inserting a block from another file and then deleting them and reopening block manager will cause the effect as seen on screens - after purge v6 hides it after inserting few more and deleting them from doc through block manager and again on next reopen of block manager it shows previously purged + new ones as “Error: No geometry …” entries