Python Scripting

Wrap supports Python for project script and parameter expressions.

Tip

Currently Python 3.8.3 is using.

Python Parameter Expression

A new scripting button is located next to a majority of node parameters indicating that the parameter is scriptable.

../_images/PythonScriptingButton.jpg

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.

../_images/PythonExpressionEditor.png

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, seven 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.

  • galleryDir() returns value of $GALLERY_DIR.

  • projectDir() returns value of $PROJECT_DIR.

  • projectName() returns value of $PROJECT_NAME.

  • projectPath() returns the absolute file path of project, or empty string if it wasn’t saved.

Python 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.

Go to File >> Edit Project Script or click CTRL + I to open the Project Script Editor dialog.

../_images/PythonProjectScriptEditor.png