rs.ProjectPointToMesh is not returning a list as expected

When using rs.ProjectPointToMesh the documentation says that it will return a list of points. Instead this is happening. It is not a Python list and does not behave like a Python list.

print(Above)
print( type(Above) )

Rhino.Geometry.Point3d[]
<class 'Rhino.Geometry.Point3d[]'>

There is a couple hours of my life that I will never get back…

Yes, there are certain methods that return a RhinoCommon Point3dList object and not a normal list. The workaround is to just use

mylist = list(my_point3dlist)

to convert it to a normal Python list.

1 Like

Thanks, this is a little better than my current work around.

I should have added that rs.ProjectPointToMesh worked properly in Rhino 7 but does not in Rhino 8. It changed. I thought the transition from 7 to 8 was going to be easier but it took the whole day to track little issue that were not there before.

I tested via the EditPythonScript editor in V7:

import rhinoscriptsyntax as rs
import Rhino
pt_ids=rs.GetObjects("Select points",1,preselect=True)
if pt_ids:
    mesh_id=rs.GetObject("Select mesh",32)
    if mesh_id:
        dir_vec=Rhino.Geometry.Vector3d(0,0,-1)
        result=rs.ProjectPointToMesh(pt_ids,mesh_id,dir_vec)
        print(result[0])
        print(type(result))

Output:
1,1,0
<type 'Array[Point3d]'>

Same script in V8 in ScriptEditor with #! python 2:

Output :
1,1,0
<type 'Array[Point3d]'>

Same script in V8 in ScriptEditor with #! python3:

Output:
1,1,0
<class 'Rhino.Geometry.Point3d[]'>

So yes, there is a difference, but one still seems to be able to parse the list by index.
Not all the rhinoscriptsyntax methods have been adapted for python 3 and I’m sure there will need to be some fixes, as well as some adaptation by people who write scripts.

Ok great. I just tested this and it works in 8.4 RC

test_array_index.3dm (36.6 KB)
test_array_index.py (360 Bytes)
test_array_index_ironpython.py (375 Bytes)