point_to_compas can convert Point3d to compas-point object.
However, when the point is converted from rs.coercerhinoobject(pt).Geometry inside a GHpython script, the default result is Rhino.Geometry.Point instead of Rhino.Geometry.Point3d
using the current code of point_to_compas, this will result in a error: AttributeError: 'Point' object has no attribute 'X'
Based on here, in such case, we need to use pt.Location to get the coordinate, which is also a valid input for point_to_compas.
To Reproduce
Steps to reproduce the behavior:
In GHPython, make a python script (IronPython):
Inside:
# if Guid, convert to Rhino Object
import compas_rhino.conversions as cnv
import Rhino.Geometry as rg
import rhinoscriptsyntax as rs
import System.Guid
if type(obj) == System.Guid:
obj = rs.coercerhinoobject(obj).Geometry
obj_type = type(obj)
if obj_type == rg.Point:
print("converting to point")
res1 = cnv.point_to_compas(obj)
res2 = cnv.point_to_compas(obj.Location)
Expected behaviorres1 should work. But only res is working.
Screenshots
Desktop (please complete the following information):
OS: Windows
Python version: IronPython
Additional context
Should be a simple fix. So I didn't bother to create a PR. If you need, a PR is also possible.
Describe the bug
point_to_compas
can convertPoint3d
to compas-point object. However, when the point is converted fromrs.coercerhinoobject(pt).Geometry
inside a GHpython script, the default result isRhino.Geometry.Point
instead ofRhino.Geometry.Point3d
using the current code of
point_to_compas
, this will result in a error:AttributeError: 'Point' object has no attribute 'X'
Based on here, in such case, we need to use
pt.Location
to get the coordinate, which is also a valid input forpoint_to_compas
.To Reproduce Steps to reproduce the behavior:
Expected behavior
res1
should work. But onlyres
is working.Screenshots
Desktop (please complete the following information):
Additional context Should be a simple fix. So I didn't bother to create a PR. If you need, a PR is also possible.