Extract block from Rhino file without opening it?

Hi All,

I know it is not possible in Rhino but I was wondering if it is possible via scripting to import just specific block definitions from Rhino file without opening it? At some point @clement wrote a script to do so with just selected NamedViews - can that be done with blocks as well?

In general I think it may be on a wish pile but I can’t find it for a way to import pieces of the model or other information from Rhino files without opening them. I would find it very useful.



Hi @Jarek,
This should be possible via the File3dm class’ https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_FileIO_File3dm.htm

There is the AllInstanceDefinitions property to give you back the blocks from a .3dm file.
I don’t have an example for that though…

1 Like

thanks Lando! I will look into that…

Some time ago I had to extract volume properties from blocks within files. As @lando.schumpich suggested I used the File3dm object. It still opens the file, but it doesn’t become the active document in the Rhino instance it is read from.

Indeed the .AllInstanceDefinitions property will give you a table of Rhino.Geometry.InstanceDefinitionGeometry objects. Also there is the .InstanceDefinitions which just gives a list. Once you have those, I don’t see a smooth way to import them into the current doc. I think you would have to decompose them down to the geometry objects, name, and insertion point in order to to add new instance definitions to the active doc’s InstanceDefinitionsTable. Maybe there is a way, but I missed it.

If you are wanting to import references, I had to parse the object table and find the InstanceReferences:

for obj in fileIOObject.Objects:
    if obj.Geometry.ObjectType == R.DocObjects.ObjectType.InstanceReference:

I couldn’t ever find a File3dm equivalent to the Rhino.DocObjects.InstanceDefinition.GetReferences() function.

I’m hitting the same wall… Dear @dale would you mind point us how to put InstanceDefinitionGeometry in active doc as InstanceDefinition - maintaing all original elements including URL?

Hi @D-W,

Are you looking for this?


– Dale

Hi @dale those are the ones which i know and i dont see there URL option besides wouldnt it be easier if it would be directly passable to idef table? I need urls as some renderers uses it as a pointer to their original model while block is proxy.

Oh sorry does the URL from object attributes populate the URL of idef?

It doesn’t matter as File3dmObject with InstanceDefinitionGeometry has wrong Attributes - IsInstanceDefinitionObject is false for those - I guess that attributes check that in relation to the current doc besides those are attributes of InstanceObject not the definition. Or it’s not part of as it is an InstanceDefinition but without its properties and with useless GeometryBase stuff - to be honest, I don’t get that logic here as normally API is made like never to confuse instance def with the current object in object table but when it comes to reading the file it is boxed to InstanceDefinitionGeometry without the possibility of unboxing?

Hi @D-W,

I’ll see to adding an additional override that lets you pass a URL.


– Dale

1 Like

Cool thanks @dale! I guess YT issue is still not public :wink: Anyway, would you mind pointing me cpp method for that maybe i’ll be able to hook to rhcommon_c on my own for that?

Dear @dale, I really appreciate filling this gap and I am waiting for SR with it and sorry for the inconvenience but it seems we have also trouble on the other end as I don’t see any reasonable way to get URL from this and this is the only container carrying definition object from my research.

Hi @D-W,

You won’t find any URL property on InstanceDefinitionGeometry. You will, however, find it on it’s parent runtime object, InstanceObject. just look at its Attributes property.

Also, if you have an InstanceObject, you can also find a URL field on it’s InstanceDefinition object.

– Dale

Hi @dale

OK so how do i read URL from File3dm without opening the doc? As on reading theres no runtime InstanceObject at all and there is no way to make identical one. The only way to add such block is to create new one using GetObjectsIds, no way to use the one and only container of that data InstanceDefinitionGeometry (against rational thinking) so URL is lost. And only way to get runtime InstanceObject is opening the file.

Theres no way of doing this. Am I missing sth still?

I sucessfuly rebuilded it with reflection basing on this, this and this

For 0 and 1 result is as expected 2, 3 and 4 are unavailable so this is missing in “rhcommon_c” I guess as here its on place.

Mhm… indeed seems to be missing here

Hi @D-W,

I’ve logged an issue for the missing Url and UrlDescription properties on InstanceDefinitionGeometry.


– Dale

1 Like

Thank you very much @dale for putting it on a pile!