From 1667ef27ecc667cc100865dbae86791422366d8f Mon Sep 17 00:00:00 2001 From: Chen Kasirer Date: Wed, 13 Nov 2024 16:58:32 +0100 Subject: [PATCH] Rhino.from_extrusion also takes Polyline --- CHANGELOG.md | 2 ++ src/compas/geometry/brep/brep.py | 2 +- src/compas_rhino/geometry/brep/brep.py | 10 ++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c2d40780e86..7911ef36bd5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +* Added support for `Polyline` as input for `compas_rhino.Brep.from_extrusion`. + ### Removed diff --git a/src/compas/geometry/brep/brep.py b/src/compas/geometry/brep/brep.py index 78028ef1236e..a8dc6fbf2d2f 100644 --- a/src/compas/geometry/brep/brep.py +++ b/src/compas/geometry/brep/brep.py @@ -392,7 +392,7 @@ def from_extrusion(cls, curve, vector, cap_ends=True): Parameters ---------- - curve : :class:`compas.geometry.Curve` + curve : :class:`compas.geometry.Curve` or :class:`compas.geometry.Polyline` The curve to extrude vector : :class:`compas.geometry.Vector` The vector to extrude the curve by diff --git a/src/compas_rhino/geometry/brep/brep.py b/src/compas_rhino/geometry/brep/brep.py index cdb4e6b37763..ee3a25e2a1a0 100644 --- a/src/compas_rhino/geometry/brep/brep.py +++ b/src/compas_rhino/geometry/brep/brep.py @@ -10,6 +10,7 @@ from compas.geometry import Frame from compas.geometry import Plane from compas.geometry import Point +from compas.geometry import Polyline from compas.tolerance import TOL from compas_rhino.conversions import box_to_rhino from compas_rhino.conversions import curve_to_compas @@ -19,6 +20,7 @@ from compas_rhino.conversions import mesh_to_rhino from compas_rhino.conversions import plane_to_rhino from compas_rhino.conversions import point_to_rhino +from compas_rhino.conversions import polyline_to_rhino_curve from compas_rhino.conversions import sphere_to_rhino from compas_rhino.conversions import transformation_to_rhino from compas_rhino.conversions import vector_to_rhino @@ -223,7 +225,7 @@ def from_extrusion(cls, curve, vector, cap_ends=True): Parameters ---------- - curve : :class:`~compas.geometry.Curve` + curve : :class:`~compas.geometry.Curve` or :class:`~compas.geometry.Polyline` The curve to extrude. vector : :class:`~compas.geometry.Vector` The vector to extrude the curve along. @@ -235,7 +237,11 @@ def from_extrusion(cls, curve, vector, cap_ends=True): :class:`~compas_rhino.geometry.RhinoBrep` """ - extrusion = Rhino.Geometry.Surface.CreateExtrusion(curve_to_rhino(curve), vector_to_rhino(vector)) + if isinstance(curve, Polyline): + rhino_curve = polyline_to_rhino_curve(curve) + else: + rhino_curve = curve_to_rhino(curve) + extrusion = Rhino.Geometry.Surface.CreateExtrusion(rhino_curve, vector_to_rhino(vector)) if extrusion is None: raise BrepError("Failed to create extrusion from curve: {} and vector: {}".format(curve, vector)) rhino_brep = extrusion.ToBrep()