Rhino.FileIO.File3dm.Read problem

Hi there,

i’m trying to import a named mesh object from a file using:

f = Rhino.FileIO.File3dm.Read(file_name)

If i query eg. f.Objects.Count it gives the right amount of objects in the file. However if i iterate over the file’s object table like below, it only lists the breps in the file:

for obj in f.Objects.GetEnumerator():
    print obj

using f.Dump() i can see that all objects are listed, including my named mesh. How can i find the mesh object by it’s name and import it from the file ?

thanks,
c.

Hi @clement,

An iterative search will work.

#! python3
import Rhino

model = Rhino.FileIO.File3dm.Read('/Users/Dale/Downloads/test.3dm')
print(model.Objects.Count)
for obj in model.Objects:
    obj_type = obj.Geometry.ObjectType
    print(obj_type)
    if obj_type == Rhino.DocObjects.ObjectType.Mesh:
        name = obj.Attributes.Name
        if name:
            print(name)

– Dale

Hi @dale, thank you for your example. It works and i have no idea why my IronPython code failed 2 days ago. The only difference is GetEnumerator().

thanks,
c.