Rhino3dm InstanceDefinitions


I’m trying to read information out of the InstanceDefinitionTable to sort through blocks and export them. I can access all other information in the file (materials, layers, views etc.etc.) but the instance definitions only return a NoneType object. The instance references themselves refer to the correct UUID (ParentIdefId).

I attached the test files if anyone wants to give it a try. I ran it from a python virtualenv as well as from the blender python console and got the same results, as well as on my laptop. I also checked Rh5 and Rh6 files and tried a clean file without any plugin data etc.

I wonder if this is a bug or if I am missing something substantial?

test.py (1.4 KB) test.rh6.3dm (72.4 KB)

Looks like a bit of copy/paste error has creeped in the code base:

I have logged an issue for this https://github.com/mcneel/rhino3dm/issues/124

I just updated rhino3dm to a new version on pypi.org (v0.7.2) with a fix for this.

1 Like

wow, that was lightning quick! just tested it, work likes a charm.

thanks to you guys for looking into it and fixing it =)

I ran into another issue here. I can build a hierarchy using the InstanceDefinitionTable and the Object.Attributes.ParentIdefId. Unfortunately I cant get a list of the InstanceDefinitions geometry (references or guids). Trying it the other way round also doesn’t work, since the Object.Attributes.IsInstanceDefinitionObject is just a boolean, so I cant refer to the definition it belongs to.

I guess we would need the equivalent to rhinocommons InstanceDefinition.GetObjects() (link)?
Also, the InstanceDefinitions dont expose the Names or IDs, just the Description (especially the names would be helpful for subsequent naming of exported Objects)

1 Like

@fertig, feel free to log issues in the GitHub project for rhino3dm, that way bugs and info about missing bits reach us even faster :slight_smile:

1 Like

Will do so! Then again, the other day i thought: Instead of just throwing stuff at you guys, I could at least have a look at it. I’m by no means a c++ expert, but it turns out the pybind basics were easy enough to grasp to implement the properties. The idef.Id and idef.Name are working over here.

I got a bit stuck though with the ON_SimpleArray<ON_UUID> reference that InstanceGeometryIdList() returns. Is there any pretty way to cast this to something pybind would recognize? The only way i see right now is to iterate over the whole thing and follow the way that ON_UUID_to_Binding goes by converting it to a string first…

@stevebaer, can you help with the pybind part here, please?

ahhhh nevermind me spamming around here… once i included pybind11/stl.h in my minimal example i got it working.

blessed is he that readeth the documentation thoroughly :wink:

Sure, just make sure there is an issue on github. Arrays in general are a bit trickier to work with so it will take a little extra effort to figure out what to do here.

i filed the issue here =)


1 Like