Skip to content

Commit

Permalink
use try except
Browse files Browse the repository at this point in the history
  • Loading branch information
Licini committed Apr 29, 2024
1 parent 7b5b5e3 commit 9454699
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +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 `compas.geometry.Point` as input.
* Updated `compas_rhino.conversions.point_to_compas` to allow for `Rhino.Geometry.Point` as input.

### Removed

Expand Down
12 changes: 7 additions & 5 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 @@ -110,12 +111,13 @@ def point_to_compas(point):
:class:`compas.geometry.Point`
"""
if isinstance(point, Rhino.Geometry.Point3d):
try:
return Point(point.X, point.Y, point.Z)
elif isinstance(point, Rhino.Geometry.Point):
return Point(point.Location.X, point.Location.Y, point.Location.Z)
else:
raise TypeError("Expected Rhino.Geometry.Point3d or Rhino.Geometry.Point., got: {}".format(type(point)))
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

0 comments on commit 9454699

Please sign in to comment.