Skip to content

Commit 9454699

Browse files
committed
use try except
1 parent 7b5b5e3 commit 9454699

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
* Changed use of `compas.geometry.allclose` to `compas.tolerance.TOL.is_allclose`.
3535
* Changed use of `compas.geometry.close` to `compas.tolerance.TOL.is_close`.
3636
* Changed imports of itertools to `compas.itertools` instead of `compas.utilities`.
37-
* Updated `compas_rhino.conversions.point_to_compas` to allow for `compas.geometry.Point` as input.
37+
* Updated `compas_rhino.conversions.point_to_compas` to allow for `Rhino.Geometry.Point` as input.
3838

3939
### Removed
4040

src/compas_rhino/conversions/geometry.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import print_function
44

55
import Rhino # type: ignore
6+
from System import MissingMemberException # type: ignore
67

78
from compas.geometry import Frame
89
from compas.geometry import Plane
@@ -110,12 +111,13 @@ def point_to_compas(point):
110111
:class:`compas.geometry.Point`
111112
112113
"""
113-
if isinstance(point, Rhino.Geometry.Point3d):
114+
try:
114115
return Point(point.X, point.Y, point.Z)
115-
elif isinstance(point, Rhino.Geometry.Point):
116-
return Point(point.Location.X, point.Location.Y, point.Location.Z)
117-
else:
118-
raise TypeError("Expected Rhino.Geometry.Point3d or Rhino.Geometry.Point., got: {}".format(type(point)))
116+
except MissingMemberException:
117+
try:
118+
return Point(point.Location.X, point.Location.Y, point.Location.Z)
119+
except MissingMemberException:
120+
raise TypeError("Unexpected point type, got: {}".format(type(point)))
119121

120122

121123
def vector_to_compas(vector):

0 commit comments

Comments
 (0)