Hi, there seems to be a bug in rs.coerce3dpoint() in Rhino 8.
In v7 I can use:
rs.coerce3dpoint(vertices[n])
but in v8 I have to use:
rs.coerce3dpoint((vertices[n].X,vertices[n].Y,vertices[n].Z))
Is this a change that I have to adopt to or is it a bug?
the error I get is:
Message: object of type ‘Point3f’ has no len()
I found this when running a script that uses the planes of vertices: plane = rs.PlaneFromNormal(vertices[n], normals[n])
But now I have to use plane = rs.PlaneFromNormal(rs.coerce3dpoint((vertices[n].X,vertices[n].Y,vertices[n].Z)), rs.coerce3dvector((normals[n].X,normals[n].Y,normals[n].Z)))
I do see a one line difference in the code for coerce3dpoint in V8 vs v7:
V7:
def coerce3dpoint(point, raise_on_error=False):
"""Converts input into a Rhino.Geometry.Point3d if possible.
Parameters:
point = Point3d, Vector3d, Point3f, Vector3f, str, uuid
raise_on_error [opt] = True or False
Returns:
a Rhino.Geometry.Point3d
Example:
See Also:
"""
if type(point) is Rhino.Geometry.Point3d: return point
enumerable = __host.Coerce3dPointFromEnumerables(point)
if enumerable is not None: return enumerable
if type(point) is System.Guid:
found, pt = scriptcontext.doc.Objects.TryFindPoint(point)
if found: return pt
if hasattr(point, "__len__") and len(point)==3 and hasattr(point, "__getitem__"):
try:
return Rhino.Geometry.Point3d(float(point[0]), float(point[1]), float(point[2]))
except:
if raise_on_error: raise
if type(point) is Rhino.Geometry.Vector3d or type(point) is Rhino.Geometry.Point3f or type(point) is Rhino.Geometry.Vector3f:
return Rhino.Geometry.Point3d(point.X, point.Y, point.Z)
if type(point) is str:
point = point.split(',')
return Rhino.Geometry.Point3d( float(point[0]), float(point[1]), float(point[2]) )
if hasattr(point, "__len__") and len(point)==2 and hasattr(point, "__getitem__"):
try:
return Rhino.Geometry.Point3d(float(point[0]), float(point[1]), 0.0)
except:
if raise_on_error: raise
if raise_on_error: raise ValueError("Could not convert %s to a Point3d" % point)