Skip to content

Commit

Permalink
Rhino.from_extrusion also takes Polyline
Browse files Browse the repository at this point in the history
  • Loading branch information
chenkasirer committed Nov 13, 2024
1 parent 649a844 commit 1667ef2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion src/compas/geometry/brep/brep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions src/compas_rhino/geometry/brep/brep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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()
Expand Down

0 comments on commit 1667ef2

Please sign in to comment.