FoundationPartsOperationsProject (footprint)

Project (footprint)

Project(shape, target_plane_name) gives the footprint of a solid on a world plane through the origin ("XY", "YZ" or "XZ"). The result is a flat face covering exactly what the solid covers when you look straight along that plane’s normal. Above, a 30 × 20 × 10 block tilted 30° (blue) casts its shadow on the XY plane (orange): 30 × (20·cos 30° + 10·sin 30°) = 670 mm².

Curved faces work too. A bar lying across the view casts a clean rectangle, because each curved face is cut along its silhouette before projecting.

Use the footprint for nesting and clearance checks, or as a 2D outline for later operations.

from cadbuildr.foundation import *


def _tilted_block(part, length=30, width=20, height=10, tilt_deg=30):
    """A 30×20×10 block standing 15 mm up, tilted about the X axis."""
    s = Sketch(part.xy())
    block = Extrusion(Rectangle.from_center_and_sides(s.origin, length, width), height)
    return MoveBody(
        block,
        translation=Point3D(0, 0, 15),
        rotation_angle=tilt_deg,
        rotation_axis=Point3D(1, 0, 0),
    )


class TiltedBlock(Part):
    def __init__(self):
        self.add_operation(_tilted_block(self))
        self.paint("light_blue")


class Footprint(Part):
    """Project: the block's shadow on the XY plane — a flat face covering
    exactly what the block covers seen from above."""

    def __init__(self):
        self.add_operation(Project(_tilted_block(self), "XY"))
        self.paint("dark_orange")


class ProjectFootprint(Assembly):
    def __init__(self):
        self.add_component(TiltedBlock())
        self.add_component(Footprint())


show(ProjectFootprint())