mcneel / rhino3dm

Libraries based on OpenNURBS with a RhinoCommon style
MIT License
592 stars 135 forks source link

InstanceDefinition missing Attributes/Methods #126

Closed lfertig closed 4 years ago

lfertig commented 4 years ago

Instance definitions don't expose several attributes and methods. The 3 most important ones to provide basic functionality would probably be InstanceDefinition.Id, InstanceDefinition.Name and .GetObjectIds(), as listed in the .net docs: https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_Geometry_InstanceDefinitionGeometry.htm.

forum thread: https://discourse.mcneel.com/t/rhino3dm-instancedefinitions/89904/5?u=fertig

mcneel-build commented 4 years ago

Linked with RH3DM-55

lfertig commented 4 years ago

First things first, I am new to contributing something here and assume people are fare more experienced with most matters. Hence I'm open to any guidance, (constructive) criticism and if someone feels this should rather be handled by someone else, please feel free to say so.

I had a moment to look at the python binding and would propose to store the ObjectIds in an std::vector which then can be bound as an opaque stl container by pybind. This way the resulting object in python behaves like a simple list of uuids:

image

As for the conversion from ON_SimpeArrayto std::vector, do i see this correctly that this HAS to be done by first converting it to an array of strings (suuid) and from there to the respective python/wasm types?

I attached the two files of my minimal example: main.zip

lfertig commented 4 years ago

I implemented this in my forked branch, making additions to bnd_instance.h/cpp and bnd_uuid.h/cpp. Maybe you can have a look at it when you find a moment, to see if this is how you would like it to be handled?

I tested it with various files of different complexity and different levels of nested blocks. You can recreate the .3dm block hierarchy in python using the new properties and function.

mcneel-build commented 4 years ago

Closed via RH3DM-55