Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/rhino point conversion #1346

Merged
merged 3 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Changed use of `compas.geometry.allclose` to `compas.tolerance.TOL.is_allclose`.
* Changed use of `compas.geometry.close` to `compas.tolerance.TOL.is_close`.
* Changed imports of itertools to `compas.itertools` instead of `compas.utilities`.
* Updated `compas_rhino.conversions.point_to_compas` to allow for `Rhino.Geometry.Point` as input.

### Removed

Expand Down
11 changes: 9 additions & 2 deletions src/compas_rhino/conversions/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import print_function

import Rhino # type: ignore
from System import MissingMemberException # type: ignore

from compas.geometry import Frame
from compas.geometry import Plane
Expand Down Expand Up @@ -103,14 +104,20 @@ def point_to_compas(point):

Parameters
----------
point : :rhino:`Rhino.Geometry.Point3d`
point : :rhino:`Rhino.Geometry.Point3d` | :rhino:`Rhino.Geometry.Point`

Returns
-------
:class:`compas.geometry.Point`

"""
return Point(point.X, point.Y, point.Z)
try:
return Point(point.X, point.Y, point.Z)
except MissingMemberException:
try:
return Point(point.Location.X, point.Location.Y, point.Location.Z)
except MissingMemberException:
raise TypeError("Unexpected point type, got: {}".format(type(point)))


def vector_to_compas(vector):
Expand Down
Loading