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

Fix multisection sweep for sketches #1408

Merged
merged 5 commits into from
Oct 4, 2023
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
6 changes: 5 additions & 1 deletion cadquery/cq.py
Original file line number Diff line number Diff line change
Expand Up @@ -3804,7 +3804,11 @@ def _sweep(
thisObj = Solid.sweep(f, p, makeSolid, isFrenet, mode, transition)
toFuse.append(thisObj)
else:
sections = self.ctx.popPendingWires()
if self.ctx.pendingWires:
sections = self.ctx.popPendingWires()
else:
sections = [f.outerWire() for f in self._getFaces()]

thisObj = Solid.sweep_multi(sections, p, makeSolid, isFrenet, mode)
toFuse.append(thisObj)

Expand Down
6 changes: 6 additions & 0 deletions cadquery/occ_impl/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@

from ..utils import cqmultimethod as multimethod

# change default OCCT logging level
from OCP.Message import Message, Message_Gravity

for printer in Message.DefaultMessenger_s().Printers():
printer.SetTraceLevel(Message_Gravity.Message_Fail)

import OCP.TopAbs as ta # Topology type enum
import OCP.GeomAbs as ga # Geometry type enum

Expand Down
2 changes: 1 addition & 1 deletion doc/sketch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,4 @@ Reusing of existing sketches is needed when using :meth:`~cadquery.Workplane.lof

result = Workplane().placeSketch(s1, s2.moved(Location(Vector(0, 0, 3)))).loft()

When lofting only outer wires are taken into account and inner wires are silently ignored.
When lofting only outer wires are taken into account and inner wires are silently ignored. Note that only sketches on the top of stack are considered for the current operation (i.e. there are no pending sketches), so when lofting or sweeping all relevant sketches have to be added in one `placeSketch` call.
12 changes: 12 additions & 0 deletions tests/test_cadquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -5342,6 +5342,18 @@ def testSketch(self):
)
assert r5.val().Volume() == approx(0.5)

p = Workplane("XZ").spline([(0, 0), (0, 1), (2, 1)]).val()
s1 = Sketch().circle(0.5)
s2 = Sketch().circle(1)

r6 = (
Workplane()
.placeSketch(s1.moved(p.locationAt(0)), s2.moved(p.locationAt(1)))
.sweep(p, multisection=True)
)

assert r6.val().isValid()

def testCircumscribedPolygon(self):
"""
Test that circumscribed polygons result in the correct shapes
Expand Down