Table of Contents



What is Expression?

Expression, or Expr for short, is the scripting language used by PlanetCNC software for calculations, automation logic, machine customization, user interface extensions, and integration tasks.

Expr lets you change and extend behavior without recompiling the application. This is useful because CNC machines and automation systems are often configured differently: different inputs, outputs, sensors, tools, workflows, safety rules, and external devices may need different logic.

Expr can be used like a powerful calculator, but it is also used as a scripting layer for PlanetCNC workflows. Expr scripts can be called from G-code, used to create custom dialogs and forms, and used as an alternative to G-code scripts for larger automation tasks.


What Expr Is Used For

Expr is used for tasks such as:

For example, Expr can calculate a value, check a condition, choose what should happen next, show a custom dialog, run probing logic, or execute a tool-change sequence.


What Expr Is Not

Expr is intentionally focused. It is not meant to replace every programming language or every part of the control system.

Expr is not:

Expr is best used for customization, automation, integration, and runtime logic inside PlanetCNC.


How Expr Looks

Expr uses familiar syntax for numbers, variables, operators, conditions, loops, and functions.

a = 10;
b = 20;
 
result = a + b;
 
if(result > 25)
{
    'large';
}
else
{
    'small';
};

In this example:


How To Read These Tutorials

If you are new to Expr, read the tutorial pages in order. Each page introduces one small part of the language and builds on the previous page.

Next: First expression