Q100109: Parameter Expressions and adding custom functions



This article offers some clarification on parameter expressions and how you can add a custom object to them through a custom function example.



Parameter expressions only support Python expressions rather than full Python scripts.

These are analogous to the body of a lambda, or the right-hand side of a variable assignment. You can't use ordinary if/else blocks or loops, but you could use ternary operators and list comprehensions.

You can register custom objects that you can then use within a parameter expression. Here's an example showing how you can register a custom function and use this in a parameter expression:

In the Python tab, define and register your function like so:

def triple(value):
  return value * 3

NodegraphAPI.SetExpressionGlobalValue("triple", triple)

Then from a parameter expression, you could use the function like so:

triple(5) + 1

The parameter's value would then be 16. The important thing to note is that your expression must evaluate to some value rather than return some value.


The purpose of a parameter expression is to compute a parameter's value programmatically. A parameter expression should not make any modifications to your project as part of its evaluation.

If you need to drive the values of many parameters , consider using a Shelf Script or a Script Button, for which you can find more information in our Katana Technical Guide's chapter on Shelf Item Scripts and Katana User Guide's chapter on User Parameters and Widget Types. 


Keywords: Katana, custom function, parameter expression

Was this article helpful?
1 out of 1 found this helpful