Skip to content

Templates

Templates let you work with your data like a spreadsheet formula: filter lines, calculate new values, and build the names of fixtures, groups and layout rows from any field. prepare uses the Jinja2 template language.

You can use templates in these places:

WhereWhat the template does
Show Data → FilterShows only the lines for which the template is true.
Show Data → Edit DataCalculates a new value for every selected line.
Create Patch / Update Patch → Set NameThe label of each fixture.
Sorted Groups / Sub-ID Groups → Set NameThe name of the groups of one level.
Sorted Groups / Sub-ID Groups → Set GroupingWith Group by: Template, the lines with the same result end up in one group.
Multi Layout → Set GroupingOne layout per result.
Straight Layout, FX Layout, Function ID FX → Set GroupingOne row per result.
FormUse it for
{{ expression }}Insert a value, e.g. {{ short_type }}
{% if … %}…{% else %}…{% endif %}Branches, e.g. {% if z > 2 %}High{% else %}Low{% endif %}
value | filterChange a value, e.g. {{ position | upper }}. Useful filters: lower, upper, replace, round, join, length, map, max, min

The helpers abs, round, min, max, len, int, float and str are available in every template.

Typographic quotes (e.g. „Front” from a German keyboard) are converted automatically, so {{ position == „Front" }} works the same as {{ position == 'Front' }}.

Every field of a line is available by its name:

VariableField
idFixture ID
sub_idSub-fixture index
ma3_idgrandMA3 ID
ft_nameModel (symbol name)
universe, addressDMX patch
x, y, zPosition in meters
rotx, roty, rotzRotation in degrees
short_typeModel Short
funcFunction
positionPosition
function_idFunction ID
appearanceAppearance color
stageStage (grandMA3)
active, dummyTrue or false
your custom fieldse.g. {{ truss_name }} — also available as user_fields['truss_name']

And some extras:

VariableDescription
lineThe current line
linesAll lines
selectedThe selected lines (Show Data)
iIndex of the current line, starting at 0
nNumber of lines (selected lines, if any)
nameThe default name prepare would use (Set Name dialogs)
nrThe running number of the fixture (labels)
levelThe hierarchy level of the group, starting at 0 (groups)
moduleThe module name of a multi-module fixture (groups and layouts)

In the Set Name dialog, open Available variables and click a badge to insert it. A live Preview below the editor shows the result for the first fixture, or the error if the template is broken. Leave the template empty to use the default name; Reset clears it.

A filter template has to result in true or false. A result counts as false if it is empty, False, 0, none, no, [] or {} — everything else is true.

{{ universe == 1 }}
{{ position == 'Front' and z > 2 }}
{{ short_type in ['LEDBar', 'Spot'] }}
{{ id >= 100 and id < 200 }}
{{ not dummy }}
{{ x < 0 }}
{{ 'key' in func | lower }}
{{ i % 3 == 0 }}
{{ x == (lines | map(attribute='x') | max) }}
{{ line in selected }}

In the Edit Data dialog, every field accepts a template. It is calculated for every selected line and stored in the field:

  • x, y, z and the rotations accept decimal commas (1,5).
  • ID, universe, address and function ID are rounded to whole numbers.
  • All other fields are stored as text.
  • An empty result leaves the line unchanged.
{{ position }}_{{ short_type }}
{{ x * -1 }}
{{ i + 100 }}
{{ position | replace(' ', '_') | lower }}
{{ 1 + (i // 10) }}
{% if z > 2 %}High{% else %}Low{% endif %}

Everything is checked against the first line before anything is written. If the template has an error, nothing is changed.

The Set Name dialog has some Predefined templates to start with:

TemplateResult
{{ position }} {{ short_type }} {{ func | replace(' ', '-') }} {{ nr }}Stage Spot LX-1 1
{% if dummy %}D {% endif %}{{ position }} {{ short_type }} {{ nr }}D Stage Spot 1 (for dummies)
{{ short_type }} {{ nr }}Spot 1
{{ name | upper }}The default name in uppercase
{{ position }} {{ short_type }}Stage Spot (groups, layouts)
{{ short_type }} {{ func }}Spot LX 1 (layouts)