Skip to content

Commit 8d1381b

Browse files
adam-urbanczykmarcus7070
authored andcommitted
Allow to use Edge/Wire for sweep
1 parent abdb3cc commit 8d1381b

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

cadquery/cq.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3125,7 +3125,7 @@ def revolve(
31253125

31263126
def sweep(
31273127
self: T,
3128-
path: "Workplane",
3128+
path: Union["Workplane", Wire, Edge],
31293129
multisection: bool = False,
31303130
sweepAlongWires: Optional[bool] = None,
31313131
makeSolid: bool = True,
@@ -3161,8 +3161,15 @@ def sweep(
31613161
)
31623162

31633163
r = self._sweep(
3164-
path.wire(), multisection, makeSolid, isFrenet, transition, normal, auxSpine
3164+
path.wire() if isinstance(path, Workplane) else path,
3165+
multisection,
3166+
makeSolid,
3167+
isFrenet,
3168+
transition,
3169+
normal,
3170+
auxSpine,
31653171
) # returns a Solid (or a compound if there were multiple)
3172+
31663173
newS: T
31673174
if combine:
31683175
newS = self._combineWithBase(r)
@@ -3648,7 +3655,7 @@ def _revolve(
36483655

36493656
def _sweep(
36503657
self,
3651-
path: "Workplane",
3658+
path: Union["Workplane", Wire, Edge],
36523659
multisection: bool = False,
36533660
makeSolid: bool = True,
36543661
isFrenet: bool = False,
@@ -3673,7 +3680,7 @@ def _sweep(
36733680

36743681
toFuse = []
36753682

3676-
p = path.val()
3683+
p = path.val() if isinstance(path, Workplane) else path
36773684
if not isinstance(p, (Wire, Edge)):
36783685
raise ValueError("Wire or Edge instance required")
36793686

tests/test_cadquery.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,11 @@ def testSweep(self):
10151015
self.assertEqual(3, result.faces().size())
10161016
self.assertEqual(3, result.edges().size())
10171017

1018+
# Test Wire path
1019+
result = Workplane("XY").circle(1.0).sweep(path.val())
1020+
self.assertEqual(3, result.faces().size())
1021+
self.assertEqual(3, result.edges().size())
1022+
10181023
# Test with makeSolid False
10191024
result = Workplane("XY").circle(1.0).sweep(path, makeSolid=False)
10201025
self.assertEqual(1, result.faces().size())

0 commit comments

Comments
 (0)