Cannot convert from Rhino.Point to compas point using `point_to_compas`
xarthurx opened this issue · 1 comments
Describe the bug
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:
# 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 behavior
res1
should work. But only res
is working.
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.