Skip to content

Commit

Permalink
Fixed split with nested Compounds Issue #698
Browse files Browse the repository at this point in the history
  • Loading branch information
gumyr committed Oct 4, 2024
1 parent 2864f05 commit f1a9c58
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/build123d/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -2760,13 +2760,11 @@ def split(self, plane: Plane, keep: Keep = Keep.TOP) -> Self:
# Perform the splitting operation
splitter.Build()

if keep == Keep.BOTH:
result = Compound(downcast(splitter.Shape()))
else:
parts = list(Compound(downcast(splitter.Shape())))
result = Compound(downcast(splitter.Shape())).unwrap(fully=False)
if keep != Keep.BOTH:
tops = []
bottoms = []
for part in parts:
for part in result:
if plane.to_local_coords(part).center().Z >= 0:
tops.append(part)
else:
Expand Down
6 changes: 6 additions & 0 deletions tests/test_build_part.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,12 @@ def test_custom_plane(self):
split(bisect_by=Plane.YZ, keep=Keep.TOP)
self.assertAlmostEqual(test.part.volume, (2 / 3) * 1000 * pi, 5)

def test_wrapped_object(self):
obj = Box(1, 1, 1)
obj = fillet(obj.edges().group_by(Axis.Z)[-1], 0.1)
right = split(obj, bisect_by=Plane.YZ, keep=Keep.TOP)
self.assertLess(right.volume, obj.volume)


class TestThicken(unittest.TestCase):
def test_thicken(self):
Expand Down

0 comments on commit f1a9c58

Please sign in to comment.