What is Rhino.Geometry.Point3d[]

Hello,

I am using rs.ProjectPointToSurface and it is returning a Rhino.Geometry.Point3d[] object.
It does not act like a list because object[0] causes an error.
It does not act like a Rhino.Geometry.Point3d object because object.X() causes an error. So it is completely unusable. This code used to work in version 7 but not is version 8.

Here is a chunk of code with an abundance of print statements:

Here are the print statements:
Rhino Error 2

It seems like this Rhino.Geometry.Point3d[] object is some mystery object that doesn’t act like anything usable.

Am I missing something obvious?

Henry

Rhino.Geometry.Point3d[] is an array of Point3d structs.

above = rs.ProjectPointToSurface([PointOnSurface], [nominalMeshId], Direction)
if above:
  for p in above:
    x = p.X
    y = p.Y
    z = p.Z

– Dale

Thanks Dale,
I will give this a try.
Is the plan to have this return a list in a future release?

Henry

@Henry_Wede just do something like:

above = list(rs.ProjectPointToSurface([PointOnSurface], [nominalMeshId], Direction))

1 Like

That’s the workaround, but the real solution is that the method should output a real Python list like V7 did. There have been a number of instances of this happening in V8.

I wasn’t aware the API had changed. That is bad indeed if that’s the case.

I don’t use rhinoscriptsyntax myself, I’m not familiar with it. I think it is @Alain 's project?

What am I missing?
This

import rhinoscriptsyntax as rs
import Rhino


pts = rs.GetObjects("select points")
srfs = rs.GetObjects("select srfs")
dir = Rhino.Geometry.Vector3d(1, 1, -1)
result = rs.ProjectPointToSurface(pts, srfs, dir)
print (result[0][0])
print (result[0].X)

seems to work in both Rhino 7 and 8

Maybe his Rhino is not updated?

It’s a bug that only happens when running your scripts in python 3.
The bug has been logged.
Thank you for reporting it.

1 Like

@Henry_Wede Would you mind sharing a file and script that replicates the problem? I am testing the script and file attached here in Rhino 8.11 SRC with no issues on macOS or Windows. Does this script throw errors on your machine?

test_indexPointArray.py (364 Bytes)
test_indexPointArray.3dm (2.7 MB)

No, your script and example project does not cause any errors.
My mistake for not including the program version - I should have done that. It is on Windows and the details are:

Version 8 SR9
(8.9.24194.18121, 2024-07-12)
Commercial

Honestly, moving scripts that worked in V7 to V8 was/is extremely painful. Very painful. We will be buying more Rhino licenses because it is part of the solutions we deliver, but I am in no hurry to change versions unless there is a strong reason for it. I don’t have time to apply bandages and then take them off and apply other ones. It is too much. We will stick with this version and my apologies if I reported a bug that has already been fixed.

Henry

@Henry_Wede

I am sorry for the pain of converting python 2 files into python 3.

To avoid the pain, you should be able to run ALL your Rhino 7 IronPython scripts in Rhino 8 (IronPython) with no changes. To get the editor to see them as IronPython files either:

  • Change the file extension to .py2
  • Add #! python 2 as the first line of the script

Rhino 8 still ships IronPython and your existing scripts should run with no problems.

1 Like