mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-05 18:20:46 -08:00
Enhanced offset to allow holes to grow outside of the Face Issue #702
This commit is contained in:
parent
debdf845bf
commit
043629ec87
2 changed files with 15 additions and 1 deletions
|
|
@ -616,7 +616,14 @@ def offset(
|
|||
inner_wires.append(offset_wire)
|
||||
except:
|
||||
pass
|
||||
new_face = Face(outer_wire, inner_wires)
|
||||
# inner wires may go beyond the outer wire so subtract faces
|
||||
new_face = Face(outer_wire)
|
||||
if inner_wires:
|
||||
inner_faces = [Face(w) for w in inner_wires]
|
||||
new_face = new_face.cut(*inner_faces)
|
||||
if isinstance(new_face, Compound):
|
||||
new_face = new_face.unwrap(fully=True)
|
||||
|
||||
if (new_face.normal_at() - face.normal_at()).length > 0.001:
|
||||
new_face = -new_face
|
||||
new_faces.append(new_face)
|
||||
|
|
|
|||
|
|
@ -521,6 +521,13 @@ class OffsetTests(unittest.TestCase):
|
|||
offset(amount=1, kind=Kind.INTERSECTION)
|
||||
self.assertAlmostEqual(test.sketch.area, 9, 5)
|
||||
|
||||
def test_face_offset_with_holes(self):
|
||||
sk = Rectangle(100, 100) - GridLocations(80, 80, 2, 2) * Circle(5)
|
||||
sk2 = offset(sk, -5)
|
||||
self.assertTrue(sk2.face().is_valid())
|
||||
self.assertLess(sk2.area, sk.area)
|
||||
self.assertEqual(len(sk2), 1)
|
||||
|
||||
def test_box_offset(self):
|
||||
with BuildPart() as test:
|
||||
Box(10, 10, 10)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue