FoundationPartsShortcuts

Shortcuts

Every Part has one-call shortcuts that build an operation, add it to the part and return it, so the result can feed the next call:

ShortcutSame as
self.extrude(shape, depth, cut=False, end_condition=None)add_operation(Extrusion(shape, depth, ...))
self.cut_extrude(shape, depth, end_condition=None)an Extrusion with cut=True
self.revolve(shape, axis, angle=360, cut=False)Lathe (axis may be a Line)
self.fillet(solid, radius, edges=None)Fillet
self.chamfer(solid, distance, edges=None)Chamfer
self.shell(solid, thickness, faces=None)Shell
self.linear_pattern(shape, direction, count, spacing)LinearPattern
self.polar_pattern(shape, count, angle=360, axis=[0, 0, 1])PolarPattern

They produce exactly the same DAG as writing the nodes by hand.

from cadbuildr.foundation import *


class ShortcutEnclosure(Part):
    """The same operations as writing the nodes by hand, one call each.

    `self.extrude`, `self.fillet`, `self.shell`, `self.cut_extrude` and
    `self.polar_pattern` build the operation, add it to the part and return
    it, so the result can feed the next call.
    """

    def __init__(self):
        s = Sketch(self.xy())
        block = self.extrude(Rectangle.from_center_and_sides(s.origin, 60, 40), 25)
        rounded = self.fillet(block, 5, EdgeFinder(rule=ParallelToAxisRule(axis="Z")))
        self.shell(rounded, 2)

        # Four vent holes in the floor, from one hole and a circular pattern.
        vent = Extrusion(Circle(Point(s, 12, 0), 3), 2, cut=True)
        self.polar_pattern(vent, 4)
        self.paint("light_bluish_gray")


show(ShortcutEnclosure())