From 8283d7403c91427559946ee38536a4fa5847be3c Mon Sep 17 00:00:00 2001 From: Li Date: Mon, 29 Apr 2024 17:00:35 +0200 Subject: [PATCH 1/4] allow Rhino.Geometry.Point --- src/compas_rhino/conversions/geometry.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/compas_rhino/conversions/geometry.py b/src/compas_rhino/conversions/geometry.py index 118e4302e84..bb7e04bb883 100644 --- a/src/compas_rhino/conversions/geometry.py +++ b/src/compas_rhino/conversions/geometry.py @@ -103,14 +103,19 @@ 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) + if isinstance(point, Rhino.Geometry.Point3d): + 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))) def vector_to_compas(vector): From 7b5b5e3e5f66e556b8616879627bf643ce76b9ea Mon Sep 17 00:00:00 2001 From: Li Date: Mon, 29 Apr 2024 17:01:57 +0200 Subject: [PATCH 2/4] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index afce9e69104..9cb89d700b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 `compas.geometry.Point` as input. ### Removed From 94546998f95fc37bc9adf5265caef71a4809beb9 Mon Sep 17 00:00:00 2001 From: Licini Date: Mon, 29 Apr 2024 17:50:58 +0200 Subject: [PATCH 3/4] use try except --- CHANGELOG.md | 2 +- src/compas_rhino/conversions/geometry.py | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cb89d700b2..8baf02dc1b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/compas_rhino/conversions/geometry.py b/src/compas_rhino/conversions/geometry.py index bb7e04bb883..cceb72bbe7e 100644 --- a/src/compas_rhino/conversions/geometry.py +++ b/src/compas_rhino/conversions/geometry.py @@ -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 @@ -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): From 5f93bb58f6d7864aa3bc5c76ecb80346160df5cf Mon Sep 17 00:00:00 2001 From: Gonzalo Casas Date: Wed, 1 May 2024 22:18:12 +0200 Subject: [PATCH 4/4] Remove debug print statements --- src/compas_blender/scene/capsuleobject.py | 1 - src/compas_rhino/geometry/brep/brep.py | 1 - 2 files changed, 2 deletions(-) diff --git a/src/compas_blender/scene/capsuleobject.py b/src/compas_blender/scene/capsuleobject.py index 340c6d8cfef..da8f157d93e 100644 --- a/src/compas_blender/scene/capsuleobject.py +++ b/src/compas_blender/scene/capsuleobject.py @@ -64,7 +64,6 @@ def draw( vertices, faces = self.geometry.to_vertices_and_faces(u=u, v=v) mesh = conversions.vertices_and_faces_to_blender_mesh(vertices, faces, name=self.geometry.name) if shade_smooth: - print(dir(mesh)) mesh.shade_smooth() obj = self.create_object(mesh, name=name) diff --git a/src/compas_rhino/geometry/brep/brep.py b/src/compas_rhino/geometry/brep/brep.py index 1a7f8e589ce..b2e77451aa2 100644 --- a/src/compas_rhino/geometry/brep/brep.py +++ b/src/compas_rhino/geometry/brep/brep.py @@ -534,7 +534,6 @@ def slice(self, plane): if isinstance(plane, Frame): plane = Plane.from_frame(plane) curves = Rhino.Geometry.Brep.CreateContourCurves(self._brep, plane_to_rhino(plane)) - print("curves:{}".format(curves)) return [curve_to_compas(curve) for curve in curves] def split(self, cutter):