FoundationPartsOperationsFaces: sketch on a face & select faces

Faces: sketch on a face & select faces

Sketch on a face. extrusion.end_face_plane() and extrusion.start_face_plane() return the planes of an extrusion’s cap faces (SYMMETRIC extrusions included), so a boss can be sketched straight on top of a pad: Sketch(pad.end_face_plane()).

Select faces. FaceFinder(rule=…) picks faces with the same rules an EdgeFinder uses for edges (InPlaneFinderRule, InDirectionFinderRule, …). Shell uses it to choose which faces to open — above, the bottom face instead of the default top — and FullRound to choose the face to round over.

from cadbuildr.foundation import *


class PadBossCup(Part):
    """Sketching on a face, and selecting faces.

    The boss is sketched on `pad.end_face_plane()` (the pad's top face), a
    THROUGH_ALL hole is cut down its middle, and Shell opens the BOTTOM face —
    picked with a FaceFinder — instead of the default top face.
    """

    def __init__(self, pad_h=10, boss_h=15):
        s = Sketch(self.xy())
        pad = Extrusion(Rectangle.from_center_and_sides(s.origin, 50, 50), pad_h)
        top = Sketch(pad.end_face_plane())
        boss = Extrusion(Circle(top.origin, 10), boss_h)
        body = BooleanOperation(pad, [boss], BooleanOp.UNION)
        bottom = FaceFinder(rule=InPlaneFinderRule(self.xy(), 0))
        self.add_operation(Shell(body, 2, face_finder=bottom))
        self.add_operation(
            Extrusion(
                Circle(s.origin, 4),
                1,
                cut=True,
                end_condition=ExtrudeEndCondition.THROUGH_ALL_BOTH,
            )
        )
        self.paint("tan")


show(PadBossCup())