Expressions vs. Scripting
Expressions are short, one-line snippets written in Python. They have access to the object model and the Python math functions but not much else. Currently, you can’t create variables or functions. The property value will be whatever the result of the expression is. Typical math expressions and math operations (such as sin, cos, abs, etc) are supported.
Expression Syntax
Expressions are applied to properties. When they are evaluated, they are in a context that contains the current frame (time) and current object (self). When applied to node properties, self will be the same as node, and parent will be the Session. When applied to child object properties (Shapes, layers, etc), self is the shape/layer/etc, and parent is the node (or the parent Layer if the object is in a layer).
When an expression keyword is evaluated, first it is compared with the reserved keywords above. Then, it will attempt to find a property in the current object with that name. If none is found, it will attempt to find a sibling object with that name. If none is found, it’ll attempt to find a parent object with that name.
Property and object names are the internal names, called script IDs. Spaces or special characters like the dot are replaced with underscores. For example, Roto 2 becomes Roto_2 and alpha.invert becomes alpha_invert.
Differences With Normal Scripting
Usually, Object.property notation returns the actual property object. For example, Shape_1.blur would return the blur property, from which the value can be queried with the value attribute or getValue() method.
During expression evaluation Object.property refers to the actual value at the current time. For example, Shape_1.blur would return the shape’s blur value at the current time.
In order to get a value at a different time, you must resort to long-hand notation and use the object’s property() method to return the actual property, then get the value from that, i.e. Shape_1.property(“blur”).getValue(other_time)
Point properties that represent normalized or world coordinates will be converted to and from session world pixels automatically inside expressions. This allows point controls in nodes with a unit coordinate system to be mapped into session world space, and vice-versa, automatically.