mirror of
https://github.com/gumyr/build123d.git
synced 2026-01-30 04:10:34 -08:00
Refactored Extrude to_extrude from local faces to global
This commit is contained in:
parent
1dd506a226
commit
07193a844a
3 changed files with 20 additions and 24 deletions
|
|
@ -48,14 +48,6 @@ with BuildPart() as multiple:
|
|||
Text("Ω", fontsize=3, halign=Halign.CENTER, valign=Valign.CENTER)
|
||||
Extrude(amount=1)
|
||||
|
||||
# Extrude provided face on multiple faces & subtract
|
||||
with BuildSketch() as rect:
|
||||
Rectangle(7, 7)
|
||||
with BuildPart() as single_multiple:
|
||||
Box(10, 10, 10)
|
||||
with Workplanes(*single_multiple.faces()):
|
||||
Extrude(rect.faces()[0], amount=-2, mode=Mode.SUBTRACT)
|
||||
|
||||
# Non-planar surface
|
||||
with BuildPart() as non_planar:
|
||||
Cylinder(10, 20, rotation=(90, 0, 0), centered=(True, False, True))
|
||||
|
|
@ -85,8 +77,8 @@ with BuildPart() as key_cap:
|
|||
# Add supporting ribs while leaving room for switch activation
|
||||
with Workplanes(Plane(origin=(0, 0, 4 * MM))):
|
||||
with BuildSketch():
|
||||
Rectangle(17.5 * MM, 0.5 * MM)
|
||||
Rectangle(0.5 * MM, 17.5 * MM)
|
||||
Rectangle(15 * MM, 0.5 * MM)
|
||||
Rectangle(0.5 * MM, 15 * MM)
|
||||
Circle(radius=5.51 * MM / 2)
|
||||
# Extrude the mount and ribs to the key cap underside
|
||||
Extrude(until=Until.NEXT)
|
||||
|
|
@ -108,8 +100,5 @@ if "show_object" in locals():
|
|||
show_object(
|
||||
multiple.part.translate((0, -20, 0)).wrapped, name="multiple pending extrude"
|
||||
)
|
||||
show_object(
|
||||
single_multiple.part.translate((0, 20, 0)).wrapped, name="single multiple"
|
||||
)
|
||||
show_object(non_planar.part.translate((20, -10, 0)).wrapped, name="non planar")
|
||||
show_object(key_cap.part.wrapped, name="key cap", options={"alpha": 0.7})
|
||||
|
|
|
|||
|
|
@ -434,8 +434,8 @@ class Extrude(Compound):
|
|||
workplane_context = WorkplaneList._get_context()
|
||||
faces, face_planes = [], []
|
||||
for plane in workplane_context.workplanes:
|
||||
for loc in list_context.local_locations:
|
||||
faces.append(to_extrude.moved(plane.to_location() * loc))
|
||||
for location in list_context.local_locations:
|
||||
faces.append(to_extrude.moved(location))
|
||||
face_planes.append(plane)
|
||||
else:
|
||||
faces = context.pending_faces
|
||||
|
|
@ -465,7 +465,7 @@ class Extrude(Compound):
|
|||
section=face,
|
||||
target_object=context.part,
|
||||
direction=plane.z_dir * direction,
|
||||
until=until
|
||||
until=until,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -218,14 +218,21 @@ class TestExtrude(unittest.TestCase):
|
|||
Extrude(amount=2.5, both=True)
|
||||
self.assertAlmostEqual(test.part.volume, 125, 5)
|
||||
|
||||
# def test_extrude_until(self):
|
||||
# with BuildPart() as test:
|
||||
# Box(10, 10, 10, centered=(True, True, False))
|
||||
# Scale(by=(0.8, 0.8, 0.8), mode=Mode.SUBTRACT)
|
||||
# with BuildSketch():
|
||||
# Rectangle(1, 1)
|
||||
# Extrude(until=Until.NEXT)
|
||||
# self.assertAlmostEqual(test.part.volume, 10**3 - 8**3 + 1**2 * 8, 5)
|
||||
def test_extrude_until(self):
|
||||
with BuildPart() as test:
|
||||
Box(10, 10, 10, centered=(True, True, False))
|
||||
Scale(by=(0.8, 0.8, 0.8), mode=Mode.SUBTRACT)
|
||||
with BuildSketch():
|
||||
Rectangle(1, 1)
|
||||
Extrude(until=Until.NEXT)
|
||||
self.assertAlmostEqual(test.part.volume, 10**3 - 8**3 + 1**2 * 8, 5)
|
||||
|
||||
def test_extrude_face(self):
|
||||
with BuildPart(Plane.XZ) as box:
|
||||
with BuildSketch(Plane.XZ, mode=Mode.PRIVATE) as square:
|
||||
Rectangle(10, 10, centered=(True, False))
|
||||
Extrude(square.sketch, amount=10)
|
||||
self.assertAlmostEqual(box.part.volume, 10**3, 5)
|
||||
|
||||
|
||||
class TestHole(unittest.TestCase):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue