Rhino3dm for python: ObjectAttributes - How to access them?

Hey,

so I’m using rhino3dm for python (3.7) on a windows-machine. I loaded a 3dmFile via python and now want to read some object attributes, basic stuff.

import rhino3dm
import tkinter
import os

#rhino3dm is a c-library
#for maximum speed, stay in library-objects as much as possible

wdir = os.path.dirname(os.path.realpath(__file__))

#string needs to be replaced with userinput
file = wdir + '/model.3dm'

print('loading model...')
model = rhino3dm.File3dm.Read(file)
print('model has been loaded')

objects = model.Objects


for i in objects:

print(i.Attributes.Name) #works 
    print(i.Attributes.Type) #Nope
print(i.Attributes.GetType) #Nope RhinoCommonSyntax
print(i.Attributes.GetType()) #Nope RhinoCommonSyntax considered Method-Syntax
    print(i.Geometry)
print('-----------------')

So what are the attributes that I can read? Is there a way to show all of the attributes given to the object-class? I tried:

print(i.Attributes.__dict__)
    print(i.Attributes.dir())

Any help or hint appreciated

print(dir(i.Attributes))

1 Like

Found out how to do it:

if you write:
help(i.Attributes)

it will give you a nicely rendered table with information about the class

Hey Nathan, thank you for that answer.

It’s a bit off-Topic, but do you know if rhino3dm supports fbx-imports? It works in rhino so I’m curious if there’s a way to put that functionality in rhino3dm.

@lesan, rhino3dm is ‘just’ an OpenNURBS wrapper. The FBX import in Rhino is handled by a plug-in.

If you want to utilize Rhino functionality beyond the fileformat reading you could try using Rhino Inside, which should now work also through CPython.

Hi @nathanletwory,
I find it difficult to understand where to start from with RhinoInside. Is there some step-by-step tutorial not involving commercial software like autocad? From some of the threads it looks like RhinoInside is similar to DLL injection into a running process :stuck_out_tongue_winking_eye:

There is a simple example CPython script to start with.

2 Likes

that’s pretty cool.

do you know if I need to have rhino installed for rhino.inside to work?

Yes, one of the requirements listed is Rhino 7 (current Rhino WIP on Windows)

1 Like