Variables from other nodes

Use variables defined on the page directly in your Python script by referencing them by name.

How It Works

Any variable created on your CalcTree page is automatically available in Python. To use it, simply start typing the variable name in your script—it will appear in the editor’s autocomplete suggestions.

This is how you pass data from the rest of the page into Python.

Example

Assume you have two variables defined elsewhere:

  • width = 100 mm

  • height = 2.5 m

In Python:

area = width * height

The result is a unit-aware calculation, where area will be added as a new Python output variable.

Notes

  • You do not need to re-declare or wrap input variables with ct.quantity()—they are already unit-aware.

  • If the variable name is misspelled or undefined, you’ll receive an error at runtime.

  • This linking works across all nodes: Maths and other Python blocks.

Last updated