OK, I see that when running it as a P3 script in ScriptEditor. It runs fine as a P2 script.
There must be something funky with the definition in the P3 rhinoscriptsyntax code - I have no idea where this actually resides, only the P2 stuff - because the error message says this:
Distance
if to_pt: return (to_pt - from_pt).Length
AttributeError: 'Point3d' object has no attribute 'Length'
Subtracting one point from another like this to_pt - from_pt results in a Vector3d object, which has a property .Length (the distance from A to B) which is returned. But somehow the results in P3 is that instead of returning a vector, it is returning a Point3d object - which has no length property.
Looks like it coerces the points, makes a vector by subtracting the two, and measures its length:
def Distance(point1, point2):
"""Measures distance between two 3D points, or between a 3D point and
an array of 3D points.
Parameters:
point1 (point): The first 3D point.
point2 (point): The second 3D point or list of 3-D points.
Returns:
point: If point2 is a 3D point then the distance if successful.
point: If point2 is a list of points, then an list of distances if successful.
None: if not successful
Example:
import rhinoscriptsyntax as rs
point1 = rs.GetPoint("First point")
if point1:
point2 = rs.GetPoint("Second point")
if point2:
print "Distance: ", rs.Distance(point1, point2)
See Also:
Angle
Angle2
"""
from_pt = coerce3dpoint(point1, True)
to_pt = coerce3dpoint(point2)
if to_pt: return (to_pt - from_pt).Length
# check if we have a list of points
to_pt = coerce3dpointlist(point2, True)
distances = [(point - from_pt).Length for point in to_pt]
if distances: return distances
What I meant by that is I didn’t know where the folder with the code for Py3 rhinoscriptsyntax was located. Now I found it. But the rs.Distance() method is the same in both.
Including what has already been demonstrated, the following shows output type discrepancies for a couple of Python 3’s Point3d’s Subtract methods and operator overloads and one Add method overload: