Expression vs. Python Editor

It is common to prototype code in the Python Editor, and you may think to do this when you need write some code for an Expression. Beware, though they look deceptively similar, the full Gaffer API is not available in expressions, and references to plugs behave quite differently.

This sometimes leads to an attempt to call something like parent["Sphere"]["radius"].getValue() in an expression, and an exception like the following :

ERROR   [Execution error] Expression1.__execute :"python/Gaffer/PythonExpressionEngine.py", line 88, in execute
line 1, in <module> AttributeError: 'float' object has no attribute 'getValue'
Continue reading “Expression vs. Python Editor”

Context Variable cheat sheet

Contexts are an essential part of Gaffer. We’re working on some more structured documentation about them. In the mean time, here is a list of common Context Variables set by Gaffer as part of the compute process. Amongst other things, they can be used in expressions or via ${variables} in string plug values.

Continue reading “Context Variable cheat sheet”