Skip to content

Commit

Permalink
Fixed workplanes popping problem Issue gumyr#399
Browse files Browse the repository at this point in the history
  • Loading branch information
gumyr committed Dec 11, 2023
1 parent 1be3656 commit b2eb1fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/build123d/build_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ def __init__(
mode: Mode = Mode.ADD,
):
self.mode = mode
self.workplanes = WorkplaneList._convert_to_planes(workplanes)
planes = WorkplaneList._convert_to_planes(workplanes)
self.workplanes = planes if planes else [Plane.XY]
self._reset_tok = None
current_frame = inspect.currentframe()
assert current_frame is not None
Expand Down Expand Up @@ -234,7 +235,6 @@ def __enter__(self):
self.builder_parent = Builder._get_context()
else:
self.builder_parent = None
self.workplanes = self.workplanes if self.workplanes else [Plane.XY]

self._reset_tok = self._current.set(self)

Expand Down
13 changes: 13 additions & 0 deletions tests/test_build_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,19 @@ def test_multiple(self):
Line((0, 0), (0, 1))
self.assertEqual(len(test.pending_edges), 2)

def test_workplane_popping(self):
# If BuildSketch pushes and pops its workplanes correctly, the order shouldn't matter
with BuildPart(Plane.XZ) as a:
with BuildSketch():
Circle(1)
Cylinder(1, 5)

with BuildPart(Plane.XZ) as b:
Cylinder(1, 5)
with BuildSketch():
Circle(1)
self.assertAlmostEqual(a.part.volume, (a.part & b.part).volume, 4)


class TestCommonOperations(unittest.TestCase):
"""Test custom operators"""
Expand Down

0 comments on commit b2eb1fb

Please sign in to comment.