Solid transforms

Renders the 3D model in your browser. The first run downloads the Python runtime (≈30 MB).
from cadbuildr.foundation import *


class TransformsAssembly(Assembly):
    """Solid-transform demos: Mirror across XZ, Scale 1.5x, BoundingBox.

    `Mirror(shape, plane_name)` reflects across "XY" / "YZ" / "XZ".
    `Scale(shape, factor)` is uniform about the world origin.
    `BoundingBox(shape)` produces an axis-aligned solid envelope.
    `Offset2D(shape, distance)` offsets a 2D closed shape on its plane.
    """

    def __init__(self):
        # Mirrored half: a tilted box, then its mirror across XZ.
        class Mirrored(Part):
            def __init__(self):
                s = Sketch(self.xy())
                box = Box(s.origin, w=10, h=5, d=3)
                self.add_operation(box)
                self.add_operation(Mirror(shape=box.expand(), plane_name=StringParameter(value="XZ")))
                self.paint("coral")

        # Scaled sphere.
        class Scaled(Part):
            def __init__(self):
                s = Sketch(self.xy())
                sphere = Sphere(s.origin, radius=4)
                self.add_operation(sphere)
                self.add_operation(Scale(shape=sphere, factor=1.5))
                self.translate([25, 0, 0])
                self.paint("nougat")

        # Bounding-box envelope of a sphere. Only the envelope is emitted —
        # fusing the sphere into its own enclosing box is a degenerate boolean.
        class Bbox(Part):
            def __init__(self):
                s = Sketch(self.xy())
                sphere = Sphere(s.origin, radius=6)
                self.add_operation(BoundingBox(shape=sphere))
                self.translate([50, 0, 0])
                self.paint("dark_bluish_gray")

        self.add_component(Mirrored())
        self.add_component(Scaled())
        self.add_component(Bbox())


show(TransformsAssembly())

Post-processing operations consume an existing solid and produce a new one:

Mirror(shape, plane_name)                 # plane_name in {"XY", "YZ", "XZ"}
Scale(shape, factor)                      # uniform about world origin
BoundingBox(shape)                        # axis-aligned envelope
Offset2D(shape, distance)                 # 2D offset of a closed shape
Section(solid, plane_name)                # cut by a world plane → wire compound

All native nodes — no @expand, direct kernel calls.

Section(solid, plane_name) cuts the solid with the given world plane and returns a wire compound of the resulting edges (in world coordinates). Useful for cross-section visualization and bounding-box queries on the cut. Re-using the section result as a 2D sketch is a separate follow-up (needs world-edges → plane-local Drawing conversion).

Non-uniform Scale (per-axis factors) is a follow-up.