File3dmObjectTable not subscriptable

Hi all

I have a problem when trying to get objects from a 3dm file by a Python script.

import Rhino
import rhinoscriptsyntax as rs

filepath = rs.OpenFileName( '3dm file ?' )
file3dm = Rhino.FileIO.File3dm.Read( filepath )
table = file3dm.Objects
print table.Count
for ix in range( table.Count ):
  obj = table[ ix ]
  print obj.Id

If I run this script, picking a 3dm file, then I get this message:

Message: ‘File3dmObjectTable’ object is not subscriptable

… referring to this line

  obj = table[ ix ]

I meant to call this:
https://developer.rhino3d.com/api/RhinoCommon/html/P_Rhino_FileIO_File3dmObjectTable_Item.htm
But it does not work.

Am I trying to do something wrong ?

Thanks

I’m not sure why this is, however this works here:

for obj in table:
    print obj.Id

If you can afford to build your own table in a list or dict, or find what you need in one loop, then maybe that could be a work around.

You’re right !
This works.
… I had not thought to try it that way …

Thanks a lot !