Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to use Edge/Wire for sweep #919

Merged
merged 1 commit into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions cadquery/cq.py
Original file line number Diff line number Diff line change
Expand Up @@ -3106,7 +3106,7 @@ def revolve(

def sweep(
self: T,
path: "Workplane",
path: Union["Workplane", Wire, Edge],
multisection: bool = False,
sweepAlongWires: Optional[bool] = None,
makeSolid: bool = True,
Expand Down Expand Up @@ -3142,8 +3142,15 @@ def sweep(
)

r = self._sweep(
path.wire(), multisection, makeSolid, isFrenet, transition, normal, auxSpine
path.wire() if isinstance(path, Workplane) else path,
multisection,
makeSolid,
isFrenet,
transition,
normal,
auxSpine,
) # returns a Solid (or a compound if there were multiple)

newS: T
if combine:
newS = self._combineWithBase(r)
Expand Down Expand Up @@ -3632,7 +3639,7 @@ def _revolve(

def _sweep(
self,
path: "Workplane",
path: Union["Workplane", Wire, Edge],
multisection: bool = False,
makeSolid: bool = True,
isFrenet: bool = False,
Expand All @@ -3657,7 +3664,7 @@ def _sweep(

toFuse = []

p = path.val()
p = path.val() if isinstance(path, Workplane) else path
if not isinstance(p, (Wire, Edge)):
raise ValueError("Wire or Edge instance required")

Expand Down
5 changes: 5 additions & 0 deletions tests/test_cadquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,11 @@ def testSweep(self):
self.assertEqual(3, result.faces().size())
self.assertEqual(3, result.edges().size())

# Test Wire path
result = Workplane("XY").circle(1.0).sweep(path.val())
self.assertEqual(3, result.faces().size())
self.assertEqual(3, result.edges().size())

# Test with makeSolid False
result = Workplane("XY").circle(1.0).sweep(path, makeSolid=False)
self.assertEqual(1, result.faces().size())
Expand Down