Export all blocks of a model

Hi there,

I am looking for a piece of python code which would export all block instances of my model in as many rhino files.
The aim is to create a folder and to save all my block definitions in the same directory. The files would be named using blocks names.

Does anybody have an idea on this ?
Thanks for your comments


You can try the script below. Blocks are always bizarre, so I don’t know how it works in all cases with nested blocks… Also, if you have more than one instances of the same name block in the file, you can’t have the same file name - so I just hacked a quick suffix add that adds a “-1” each time it encounters the same name. That will be annoying if you have hundreds of same blocks - you will have file names like "blockname-1-1-1-1-1-1-1-1-1-1-1-1-1-1" - so you will need a different renaming scheme in that case.

FWIW, --Mitch

BatchExportBlocks.py (1.1 KB)

Excellent, thank you very much, it will be good enough considering I don’t have more than one instance of the same block in my model. I just use blocks to have Xref in my model anf for their description attribute.
Thanks again

One more question,
Do you know if I can set customized Notes to the created files?
I can find a way to modify the Notes of the active rhino document but what if they are not active ?

I don’t think so… One workaround would be to copy the existing notes to a variable for later restoration. Then in the loop, replace the existing notes from the file with whatever you want to have in the exported file, then export… Repeat for each loop. At the end, restore the original notes from your variable.


Well enough, thanks again Mitch.

You realized that this functionality already existing in Rhino. In the block manager click the blocks you want and click export. It allows you to select the folder you want to export to. Although it doesn’t do the notes that you want. What would be cool is if the description got export as notes.


Nope, didn’t know about that one (never work with blocks in that way). Thanks for the info. --Mitch