Skip to content

Commit fb6cba1

Browse files
committed
Add Brep.from_loft for Rhino
1 parent a26b7e3 commit fb6cba1

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
* Added instructions for creating new data types to the dev guide.
1313
* Added `compact=False`, `minimal=False` to `compas.data.Data.to_json()` to `compas.data.Data.to_jsonstring()`.
1414
* Added `copy_guid=False` to `compas.data.Data.copy()`. If true, the copy has the same guid as the original.
15+
* Added implementation of `Brep.from_loft()` to `compas_rhino`.
1516

1617
### Changed
1718

src/compas_rhino/geometry/brep/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,8 @@ def from_sphere(*args, **kwargs):
3838
@plugin(category="factories", requires=["Rhino"])
3939
def from_mesh(*args, **kwargs):
4040
return RhinoBrep.from_mesh(*args, **kwargs)
41+
42+
43+
@plugin(category="factories", requires=["Rhino"])
44+
def from_loft(*args, **kwargs):
45+
return RhinoBrep.from_loft(*args, **kwargs)

src/compas_rhino/geometry/brep/brep.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,31 @@ def from_mesh(cls, mesh):
296296
rhino_mesh = mesh_to_rhino(mesh)
297297
return cls.from_native(Rhino.Geometry.Brep.CreateFromMesh(rhino_mesh, True))
298298

299+
@classmethod
300+
def from_loft(cls, curves):
301+
"""Construct a Brep by lofting a set of curves.
302+
303+
Parameters
304+
----------
305+
curves : list[:class:`compas.geometry.Curve`]
306+
307+
Returns
308+
-------
309+
:class:`compas.geometry.Brep`
310+
311+
"""
312+
rhino_curves = [curve_to_rhino(curve) for curve in curves]
313+
start = Rhino.Geometry.Point3d.Unset
314+
end = Rhino.Geometry.Point3d.Unset
315+
loft_type = Rhino.Geometry.LoftType.Normal
316+
317+
results = Rhino.Geometry.Brep.CreateFromLoft(rhino_curves, start, end, loft_type, closed=False)
318+
if not results:
319+
raise BrepTrimmingError("Loft operation ended with no result")
320+
result = results[0]
321+
322+
return cls.from_native(result)
323+
299324
# ==============================================================================
300325
# Methods
301326
# ==============================================================================

0 commit comments

Comments
 (0)