Python Scripting For Parameter Expressions¶
Wrap supports Python scripting for parameter expressions.
Tip
Later we will add another layer of Python scripting with functionality to add, remove, and modify nodes.
A new scripting button is located next to a majority of node parameters indicating that the parameter is scriptable.
If the parameter script is computed with errors, the scripting button turns red. If you hold the mouse over the scripting button, an error message will be displayed.
When clicking on the scripting button a Python Expression Editor dialog shows up.
A single line of code is treated as a Python expression and should return a value.
1 + 2 * 3
Multi-line code is treated as the body of a function and should end with the return
statement.
fileName = "Model.obj"
dir = "C:/Models/"
return dir + fileName
Currently, several built-in functions are supported:
frame()
returns the current frame number on the timeline.frameRange()
returns the tuple of the timeline’s start and end numbers.nodeParamValue("nodeName", "paramName")
returns the value of a parameter of a node.commonDir()
returns value of $COMMON_DIR.projectDir()
returns value of $PROJECT_DIR.galleryDir()
returns value of $GALLERY_DIR.
Project Script¶
Each Wrap project has a project script that can store Python code that is accessible from every parameter expression. In the project script you can store common functions or classes that can be repeatedly used in different places.
From the top menu please use Edit > Edit Project Script to open the Project Script Editor.