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

Calls

Workbenches and functions can get called, which just means there inner code gets executed. There are several types of calls which have some different effects or usage.

Call...ExampleInput(s)Output
functionvalue = my_function(..);parameter listValue
workbenchmodel = MySketch(..);parameter listModel1
operationnew_model = model.my_operation(..);Model1 &
parameter list
Model1

Calling Functions

A call of a function consists of just the identifier and an argument list. and the result is a value:

test

// call function -2 and store result in x
x = std::math::abs(-2);

// check value
std::debug::assert_eq([x, 2]);

Calling Workbenches

Workbenches can be called in the same way as functions except that the result is a model.

test

// call sketch Circle with a size and store object node in s
s = std::geo2d::Circle(diameter = 2cm);

std::debug::assert_eq([s.radius, 1cm]);

Calling Operations

Operations are called in a different way because they are always attached to a model which come out of workbenches.

test

// call square with a size and store object node in s
s = std::geo2d::Circle(radius = 2cm);

// translate object s
s.std::ops::translate(x = 1cm);

Surely this looks better when using thw use statement.

test

// use translate
use std::ops::translate;

// call square with a size and store object node in s
s = std::geo2d::Circle(radius = 2cm);

// translate object s
s.translate(x = 1cm);

  1. including properties. ↩2 ↩3