3dSynth

Docs / SynthBlocks

Open in the interactive docs reader

Variables

SynthBlocks supports named variables — values you define, read, and update anywhere in your program. They are especially useful inside loops where you need to accumulate or change a value on each iteration.

Creating variables

Open the Variables category in the toolbox. At the top you'll find a Create Variable button. Click it, enter a name, and a new Set Variable block is placed on the canvas.

Once a variable exists in your program, the toolbox automatically shows ready-to-use Set and Get blocks pre-filled with that variable's name under a "Your variables" section. Drag them directly onto the canvas — no need to retype the name.

To remove a variable, click the Delete button next to its name in the toolbox. This removes all Set and Get blocks for that variable from the workspace (with a confirmation prompt).

Blocks

Set Variable

Set Variable

Interactive preview is available in the interactive reader.

A statement block that assigns a numeric value to a named variable. If the variable does not exist yet, it is created. If it already exists, its value is overwritten.

FieldTypeDescription
nametextThe variable name (e.g. angle, count, offset)
valueNumberThe value to assign — accepts a fixed number or any math expression
showcheckboxWhen checked, the variable appears as an interactive control in the 3D viewport. Uncheck to hide it.

Get Variable

Get Variable

Interactive preview is available in the interactive reader.

An expression block that reads the current value of a named variable and outputs it as a Number. Plug it into any numeric input on another block.

FieldTypeDescription
nametextThe variable name to read (must match the name used in Set Variable)

Live controls in the 3D viewport

When your program contains Set Variable blocks, those variables automatically appear as interactive fields in the top-left corner of the 3D viewport, just below the auto-update controls. Each Set Variable block has a show checkbox — uncheck it to hide that variable from the viewport controls.

Each variable shows its name and a draggable numeric field (the same control used throughout the app):

The 3D preview updates immediately when you adjust a variable. This lets you experiment with values in real time without editing the blocks — perfect for fine-tuning radii, angles, offsets, and counts.

How variables work

Examples

Circles in a ring

Place 10 circles evenly spaced around a ring by accumulating an angle variable.

Setup:
1. Set Variable angle = 0
2. Repeat 10 times:
- Translate x: cos(Get angle) × 20, y: sin(Get angle) × 20
- Circle radius: 5
- Set Variable angle = Get angle + 36

Each iteration places a circle at the current angle, then advances the angle by 36° (360° / 10).

Growing radius

Draw circles with an increasing radius inside a loop.

Setup:
1. Set Variable r = 5
2. Repeat 6 times:
- Circle radius: Get r
- Set Variable r = Get r + 3

This produces circles with radii 5, 8, 11, 14, 17, 20.

Alternating offset

Offset geometry left and right on alternating layers.

Setup:
1. Set Variable dir = 1
2. For Z from 0.2 to 50, step 0.2:
- Translate x: Get dir × 2, y: 0
- Circle radius: 15
- Set Variable dir = Get dir × -1

Comparison with For Range

The For Range loop block also creates a named variable (its loop counter), but that variable only exists inside the loop body and is cleaned up afterwards. Set Variable creates persistent variables that survive beyond any enclosing block scope.

FeatureFor Range variableSet Variable
ScopeInside loop body onlyGlobal (rest of program)
Automatically updatedYes (by loop step)No (you update it manually)
Survives after loopNoYes
Readable withGet VariableGet Variable