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.