Expressions

Flux features a powerful math expression engine within the Code editor, properties, and PCB layout rules that give it spreadsheet-like superpowers.

Overview

Expressions allow you to input math functions as values in many different contexts, including the Code editor, object properties and object rules. Learn how to leverage expressions to create faster and more efficient designs.

Getting Started

In this document, we'll cover the different use-cases where you can incorporate expressions:

  • What is an Expression? learn how to integrate expressions in your project
  • Expression Results: learn how Flux shows the result of an expression
  • Basic expressions: learn how to create basic math operations and unit management.
  • Advanced expressions: learn how to work with more advanced math functions and expressions.
  • Functions: learn how to use Flux-specific additional functions.
  • Accessing object data: learn how to access properties and rules inside objects.
  • Accessing project data: learn how to access project data like a URL or description

What is an Expression?

An expression is a way to input dynamic data into a property or rule. The expression will be evaluated in real time to calculate the value of the property or rule. Let's consider the following example:

Example: Position Rule

An element's position can be defined by modifying the "Position Y" rule. The normal way would be to simply type the final position in the rule, for example 20mm

Using an expression, we could calculate the "Position Y" rule based on another rule, like "Position X". It would look like this:

Expression Results

The result of the expression will be shown right below whenever possible. This is usually the case when using expressions in properties or object-specific rules, as there is always a single result for the expression.

But when using an expression on a selector-based rule, there could be multiple results. In that case, Flux won't show the result of the expression. You will see theOutputs multiple values legend instead.

Basic Expressions

Javascript
Copy

Advanced Expressions

Flux supports most of the Math.js expressions syntax.

Javascript
Copy

Flux-specific Function Helpers

We've added a few additional electronics-oriented functions that you might find useful.

Javascript
Copy

Accessing Object Data

Accessing object data differs depending on if you're trying to access the data from within a layout rule or an object property.

Accessing Object Data from a Rule

If you're trying to access object data within a layout rule, the .thisdirective will have the following structure:

Javascript
Copy

Examples

Javascript
Copy

Accessing Object Data from a Property

If you're trying to access object data within a property, the .thisdirective will have the following structure:

Javascript
Copy

Examples

Javascript
Copy

Accessing Project Data

Project Data Schema

Javascript
Copy

Examples

Javascript
Copy
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard