FoundationPartsOperationsExtrusion end conditions

Extrusion end conditions

Extrusion(..., end_condition=ExtrudeEndCondition.X) controls how far the extrusion goes:

end_conditionMeaning
BLIND (default)from start to end
SYMMETRICtotal depth end, centred on the sketch plane
THROUGH_ALLthrough everything built so far, in the direction of end’s sign
THROUGH_ALL_BOTHthrough everything, on both sides of the sketch plane

thin_wall=t extrudes only a band of thickness t inside the profile outline. That turns a square into a square tube without a second cut.

In the bracket above, the holes are sketched on the plate’s mid-plane and cut both ways with THROUGH_ALL_BOTH. The slot is sketched 100 mm above the part and cut downward with THROUGH_ALL (negative end). The rib is a SYMMETRIC 4 mm extrusion centred on the XZ plane.

from cadbuildr.foundation import *


class EndConditionsBracket(Part):
    """Every Extrusion end condition on one part.

    - BLIND (default): the 8 mm base plate.
    - thin_wall: a square tube grown from the plate — only a 2 mm band inside
      the outline is extruded.
    - THROUGH_ALL_BOTH: mounting holes sketched on the plate's mid-plane and cut
      through everything on both sides.
    - THROUGH_ALL: a slot sketched high above the part, cut downward through
      whatever is in the way.
    - SYMMETRIC: a rib centred on the XZ plane.
    """

    def __init__(self, plate=8, tube_h=25):
        s = Sketch(self.xy())
        self.add_operation(
            Extrusion(Rectangle.from_center_and_sides(s.origin, 80, 50), plate)
        )

        top = Sketch(self.xy().get_parallel_plane(plate))
        self.add_operation(
            Extrusion(Square.from_center_and_side(top.origin, 20), tube_h, thin_wall=2)
        )

        mid = Sketch(self.xy().get_parallel_plane(plate / 2))
        holes = [Circle(Point(mid, x, y), 3) for x in (-32, 32) for y in (-17, 17)]
        self.add_operation(
            Extrusion(
                holes, 1, cut=True, end_condition=ExtrudeEndCondition.THROUGH_ALL_BOTH
            )
        )

        sky = Sketch(self.xy().get_parallel_plane(100))
        slot = SlotCenterToCenter(
            Point(sky, -25, -12), Point(sky, -25, 12), 6
        )  # 6 mm wide
        self.add_operation(
            Extrusion(slot, -1, cut=True, end_condition=ExtrudeEndCondition.THROUGH_ALL)
        )

        side = Sketch(self.xz())
        rib = Triangle(
            Point(side, 10, plate), Point(side, 30, plate), Point(side, 10, plate + 18)
        )
        self.add_operation(
            Extrusion(rib, 4, end_condition=ExtrudeEndCondition.SYMMETRIC)
        )
        self.paint("medium_azure")


show(EndConditionsBracket())