MCPcopy
hub / github.com/CadQuery/cadquery / testExtrudeUntilFace

Method testExtrudeUntilFace

tests/test_cadquery.py:3402–3564  ·  view source on GitHub ↗

Test untilNextFace and untilLastFace options of Workplane.extrude()

(self)

Source from the content-addressed store, hash-verified

3400 self.saveModel(result)
3401
3402 def testExtrudeUntilFace(self):
3403 """
3404 Test untilNextFace and untilLastFace options of Workplane.extrude()
3405 """
3406 # Basic test to see if it yields same results as regular extrude for similar use case
3407 # Also test if the extrusion worked well by counting the number of faces before and after extrusion
3408 wp_ref = Workplane("XY").box(10, 10, 10).center(20, 0).box(10, 10, 10)
3409
3410 wp_ref_extrude = wp_ref.faces(">X[1]").workplane().rect(1, 1).extrude(10)
3411
3412 wp = Workplane("XY").box(10, 10, 10).center(20, 0).box(10, 10, 10)
3413 nb_faces = wp.faces().size()
3414 wp = wp_ref.faces(">X[1]").workplane().rect(1, 1).extrude("next")
3415
3416 self.assertAlmostEqual(wp_ref_extrude.val().Volume(), wp.val().Volume())
3417 self.assertTrue(wp.faces().size() - nb_faces == 4)
3418
3419 # Test tapered option and both option
3420 wp = (
3421 wp_ref.faces(">X[1]")
3422 .workplane(centerOption="CenterOfMass", offset=5)
3423 .polygon(5, 3)
3424 .extrude("next", both=True)
3425 )
3426 wp_both_volume = wp.val().Volume()
3427 self.assertTrue(wp.val().isValid())
3428
3429 # taper
3430 wp = (
3431 wp_ref.faces(">X[1]")
3432 .workplane(centerOption="CenterOfMass")
3433 .polygon(5, 3)
3434 .extrude("next", taper=5)
3435 )
3436
3437 self.assertTrue(wp.val().Volume() < wp_both_volume)
3438 self.assertTrue(wp.val().isValid())
3439
3440 # Test extrude until with more that one wire in context
3441 wp = (
3442 wp_ref.faces(">X[1]")
3443 .workplane(centerOption="CenterOfMass")
3444 .pushPoints([(0, 0), (3, 3)])
3445 .rect(2, 3)
3446 .extrude("next")
3447 )
3448
3449 self.assertTrue(wp.solids().size() == 1)
3450 self.assertTrue(wp.val().isValid())
3451
3452 # Test until last surf
3453 wp_ref = wp_ref.workplane().move(10, 0).box(5, 5, 5)
3454 wp = (
3455 wp_ref.faces(">X[1]")
3456 .workplane(centerOption="CenterOfMass")
3457 .circle(2)
3458 .extrude("last")
3459 )

Callers

nothing calls this directly

Calls 15

WorkplaneClass · 0.85
boxMethod · 0.80
centerMethod · 0.80
extrudeMethod · 0.80
workplaneMethod · 0.80
VolumeMethod · 0.80
isValidMethod · 0.80
pushPointsMethod · 0.80
transformedMethod · 0.80
workplaneFromTaggedMethod · 0.80
sectionMethod · 0.80
rectMethod · 0.45

Tested by

no test coverage detected