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

Model Assignments

Model assignments look like value assignments but instead having a value on the right side they store a model.

test

m = std::geo2d::Circle(radius = 10mm); // assign the model of a circle into m
std::debug::assert_eq([m.radius, 10mm]); // access property radius of m

Using a model as a value or vice versa does not work without further operations.

test

m = std::geo2d::Circle(radius = 10mm); // assign the model of a circle into m
std::geo2d::Circle(radius = m); // error: cannot use m as value

Restrictions

No Shadowing

Like with value assignments so-called "shadowing" (reusing a name) is prohibited. Another assignment of a variable with the same name without an additional scope is prohibited.

Not in modules

Model assignments are not available in modules:

test

mod my_module {
    a = std::geo2d::Circle(radius = 1mm); // error
}

Not in initialization code

Model assignments are not available in workbenches' initialization code:

test

sketch MySketch() {
    a = std::geo2d::Circle(radius = 1mm); // error
    init(_x: Scalar) {}
}

MySketch();