Foundation (Python)ReferenceOperationsExtrusion

Extrusions

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


# A class for making a square tube with a given width and height and a given thickness
class SquareTube(Part):
    def __init__(self, height=100, width=20, thickness=2):
        self.height = height
        self.width = width
        self.thickness = thickness
        s = Sketch(self.xy())
        square_shape_outer = Square.from_center_and_side(s.origin, self.width)
        square_shape_inner = Square.from_center_and_side(
            s.origin, self.width - 2 * self.thickness
        )

        # 2 extrusions, first one is the outer shape, second one is a cut of the inner shape
        extrusion = Extrusion(square_shape_outer, self.height)
        extrusion2 = Extrusion(square_shape_inner, self.height, cut=True)
        self.add_operation(extrusion)
        self.add_operation(extrusion2)


show(SquareTube())

Extrusions are one of the most common operations in CAD. They are used to create 3D objects from 2D Sketches by pulling them in an orthogonal direction. An extrusion needs a closed shape, an end and start (0 by default) measurement.

# 2 extrusions, first one is the outer shape, second one is a cut of the inner shape
        extrusion = Extrusion(square_shape_outer, self.height)

Extrusion can also be given a parameter cut to remove material in the same way.