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

Property Assignments

Property assignments define additional1properties of a workbench. The may appear anywhere within the building code of a workbench and can then be read from outside.

test

sketch MySketch(radius: Length) {
    prop diameter = radius * 2;
    std::geo2d::Circle(radius);
}
std::debug::assert_eq([MySketch(5cm).diameter, 10cm])

Restrictions

Not in source files

test

prop diameter = radius * 2; // error: not in source file

Not in functions

test

fn f() {
    prop diameter = radius * 2; // error: not in functions
}

f();

Not in initialization code

test

sketch MySketch(radius: Length) {
    prop diameter = radius * 2; // error: not in initialization code

    init() {
        radius = 1;
    }
    std::geo2d::Circle(radius);
}
std::debug::assert_eq([MySketch(5cm).diameter, 10cm])

Not in initializers

test

sketch MySketch(radius: Length) {
    init() {
        radius = 1;
        prop diameter = radius * 2; // error: not in initializer
    }
    std::geo2d::Circle(radius);
}
MySketch(5cm)

  1. Additional to properties which are automatically generated from a workbench's building plan.