Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Building Code

The building code is executed after any initialization. Usually it produces one or many 2D or 3D objects on base of the given building plan.

test

sketch Wheel(radius: Length, thickness = 5mm) {
    // building code starts here
    use std::geo2d::Circle;
    Circle(radius = radius + thickness) - Circle(radius)
}
Wheel(radius = 1cm);

If initializers were defined the building code starts below them.

test

sketch Wheel(radius: Length, thickness = 5mm) {
    // initializer code
    use std::geo2d::Circle;
    // initializer
    init(diameter: Length) {
        radius = diameter / 2;
    }

    // building code starts here
    std::geo2d::Circle(radius);
}
Wheel(radius = 1cm);

Restrictions

Illegal statements within workbenches

It's not allowed to use the sketch, part, op, return nor mod statements within workbench code:

test

sketch Wheel(radius: Length) {
    sketch A() {} // error
    part B() {} // error
    op C() {} // error
}

test

sketch Wheel(radius: Length) {
    mod m {} // error
}

test

sketch Wheel(radius: Length) {
    return; // error
}