Python



FaceFX Studio supports Python for a scripting language.  Python code can be executed from the Python tab, or it can be saved out in ".py" files and executed with the exec FaceFX command.

Using the Python Tab

The python tab is a python editor built right into FaceFX Studio using wxPython.  You can execute FaceFX commands from the python shell by prepending the commands with the % character like so:

%loadActor -file ".\Samples\Slade-Maya.facefx";

Use the python tab as a test area for writing scripts. You can set variables, and even write multi-line scripts.

 

Writing Python .py Files

To gain easy access to FaceFX Python Functions, you need to import the appropriate modules.  The FxStudio module is imported by default, so you can reference its functions with FxStudio.functionName or simply functionName.  To import the FxAnimation module,  type the following:

from FxAnimation import *

You can execute FaceFX commands from a python script using the issueCommand function like so:

FxStudio.issueCommand('loadActor -file ".\Samples\Slade-Maya.fxa";')
FxStudio.issueCommand('loadActor -file "%s";'%(pythonVariable))
FxStudio.issueCommand('loadActor -file ' + pythonVariable)

 

Executing Python .py Files

Use the exec command to execute python scripts.  This command can be inserted into any FXL file, including those executed automatically by FaceFX Studio such as autoexec.fxl.

 

Reserved Python Objects

The following modules are used by FaceFX Studio internally, and over-riding these objects with user-defined variables may break python execution.  You can import these modules into your own scripts, but avoid creating variables with these names.

  • FxStudio
  • wx
  • sys

 

See Also

Python Callbacks
Python Functions
Samples & Help

 

Version Number: 
2017