Python-rhino3dm: Object name

python
unhandled
(Dimitrij Minich) #1

Hello,

does anyone know how it is possible to give an object a name. I found in the rhino3dm documentation the class rhino3dm.ObjectAttributes but I don’t understand how to use it with created objects.

Thanks for answers

0 Likes

#2

You could just use rs.ObjectName( object_id, your_object_name )…

0 Likes

(Dimitrij Minich) #3

But not in the rhino3dm. We are not talking about the same libraries. I am talking about this one:
https://github.com/mcneel/rhino3dm

0 Likes

#4

OK, I changed the topic category to rhino3dm so it’s clear…

0 Likes

(Dimitrij Minich) #5

Ah, I understand. Thx.

0 Likes

(Nathan 'jesterKing' Letwory) #6

Get the attributes, then check that for name. Here is how I used it with the 3dm importer for Blender 2.8:

0 Likes

(Dimitrij Minich) #7

I think your solution works only if you have a rhino file with objects. Then you can read the objects and get the access to the attributes. Im my case, when I create a new (for example) point:

`from rhino3dm import *`
`pt = Point3d(0,0,0)`
`pt.Attributes #<=Error because the pt object has no method like Attributes`

it doesn’t work.

0 Likes

#8

I think only Rhino objects that actually exist in a document can have “attributes”… Things like layer, color, linetype etc. Pure geometrical RhinoCommon constructions like a Point3d do not have any of those.

0 Likes

(Nathan 'jesterKing' Letwory) #9

Correct.

0 Likes

(Dimitrij Minich) #10

Ok, but it’s possible to create 3dm File with rhino3dm-library. In this file you have the “Default” layer and the objects which I created is on the default layer. Wherefrom rhino3dm knows on which layer the geometry should be created?

0 Likes

(Nathan 'jesterKing' Letwory) #11

I’m not sure how far this has been wrapped, but you set the layer of an object by setting the LayerIndex on its attributes: https://mcneel.github.io/rhino3dm/python/api/ObjectAttributes.html#rhino3dm.ObjectAttributes.LayerIndex

@stevebaer can tell you better if this is already supposed to work or not.

0 Likes

(Dimitrij Minich) #12

Ok, thank you.

0 Likes

(Steve Baer) #13

All of this is available in the rhino3dm package. You can create and add layers to a model, change object names and layer indices,…

0 Likes

(Dimitrij Minich) #14

Hi Steve,

could you make an short example how to give point object a name in rhino3dm.

0 Likes