kcl → types

std::Sketch

A sketch is a collection of paths.

When you define a sketch to a variable like:

mySketch = startSketchOn('XY')
    |> startProfileAt([-12, 12], %)
    |> line(end = [24, 0])
    |> line(end = [0, -24])
    |> line(end = [-24, 0])
    |> close()

The mySketch variable will be an executed Sketch object. Executed being past tense, because the engine has already executed the commands to create the sketch.

The previous sketch commands will never be executed again, in this case.

If you would like to encapsulate the commands to create the sketch any time you call it, you can use a function.

fn createSketch() {
   return startSketchOn('XY')
        |> startProfileAt([-12, 12], %)
        |> line(end = [24, 0])
        |> line(end = [0, -24])
        |> line(end = [-24, 0])
        |> close()
}

Now, every time you call createSketch(), the commands will be executed and a new sketch will be created.

When you assign the result of createSketch() to a variable (mySketch = createSketch()), you are assigning the executed sketch to that variable. Meaning that the sketch mySketch will not be executed again.

You can still execute new commands on the sketch like extrude, revolve, loft, etc. and the sketch will be updated.

Examples

Rendered example of std::Sketch 0

Rendered example of std::Sketch 1