mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-06 02:30:55 -08:00
Refactored sweep to generate faces within a sketch
This commit is contained in:
parent
709e67cbc5
commit
c858b10e8b
11 changed files with 248 additions and 205 deletions
|
|
@ -410,73 +410,6 @@ class TestSplit(unittest.TestCase):
|
|||
self.assertAlmostEqual(test.part.volume, (2 / 3) * 1000 * pi, 5)
|
||||
|
||||
|
||||
class TestSweep(unittest.TestCase):
|
||||
def test_single_section(self):
|
||||
with BuildPart() as test:
|
||||
with BuildLine():
|
||||
Line((0, 0, 0), (0, 0, 10))
|
||||
with BuildSketch():
|
||||
Rectangle(2, 2)
|
||||
sweep()
|
||||
self.assertAlmostEqual(test.part.volume, 40, 5)
|
||||
|
||||
def test_multi_section(self):
|
||||
segment_count = 6
|
||||
with BuildPart() as handle:
|
||||
with BuildLine() as handle_center_line:
|
||||
Spline(
|
||||
(-10, 0, 0),
|
||||
(0, 0, 5),
|
||||
(10, 0, 0),
|
||||
tangents=((0, 0, 1), (0, 0, -1)),
|
||||
tangent_scalars=(1.5, 1.5),
|
||||
)
|
||||
handle_path = handle_center_line.wires()[0]
|
||||
for i in range(segment_count + 1):
|
||||
with BuildSketch(
|
||||
Plane(
|
||||
origin=handle_path @ (i / segment_count),
|
||||
z_dir=handle_path % (i / segment_count),
|
||||
)
|
||||
) as section:
|
||||
if i % segment_count == 0:
|
||||
Circle(1)
|
||||
else:
|
||||
Rectangle(1, 2)
|
||||
fillet(section.vertices(), radius=0.2)
|
||||
# Create the handle by sweeping along the path
|
||||
sweep(multisection=True)
|
||||
self.assertAlmostEqual(handle.part.volume, 54.11246334691092, 5)
|
||||
|
||||
def test_passed_parameters(self):
|
||||
with BuildLine() as path:
|
||||
Line((0, 0, 0), (0, 0, 10))
|
||||
with BuildSketch() as section:
|
||||
Rectangle(2, 2)
|
||||
with BuildPart() as test:
|
||||
sweep(section.faces(), path=path.wires()[0])
|
||||
self.assertAlmostEqual(test.part.volume, 40, 5)
|
||||
|
||||
def test_binormal(self):
|
||||
with BuildPart() as sweep_binormal:
|
||||
with BuildLine() as path:
|
||||
Spline((0, 0, 0), (-12, 8, 10), tangents=[(0, 0, 1), (-1, 0, 0)])
|
||||
with BuildLine(mode=Mode.PRIVATE) as binormal:
|
||||
Line((-5, 5), (-8, 10))
|
||||
with BuildSketch() as section:
|
||||
Rectangle(4, 6)
|
||||
sweep(binormal=binormal.edges()[0])
|
||||
|
||||
end_face: Face = (
|
||||
sweep_binormal.faces().filter_by(GeomType.PLANE).sort_by(Axis.X)[0]
|
||||
)
|
||||
face_binormal_axis = Axis(
|
||||
end_face.center(), binormal.edges()[0] @ 1 - end_face.center()
|
||||
)
|
||||
face_normal_axis = Axis(end_face.center(), end_face.normal_at())
|
||||
self.assertTrue(face_normal_axis.is_normal(face_binormal_axis))
|
||||
|
||||
|
||||
class TestThicken(unittest.TestCase):
|
||||
def test_thicken(self):
|
||||
with BuildPart() as bp:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue