< Previous | Contents | Next >
Cross-Language Evaluation
Sometimes it is necessary or useful to call in from one language to the other to access certain features, e.g., you might want to access the Lua function dump from within Python.
With the console set to Py2 execute:
composition.Execute(“dump(comp:GetAttrs())”)
To execute the string as Python from within Lua use:
composition:Execute(“!Py: print(comp.GetAttrs())”)
To target a specific Python version use !Py2: or !Py3:
You may also want to run complete Lua or Python scripts. Use:
composition:RunScript(filePath)

Note
The shown scripts are executed in the context of the currently open composition. Hence, all the evaluation methods are members of the composition object.
If you want to execute the scripts in the context of the application, use fusion instead.
fusion:Execute(command)
fusion:RunScript(filePath)
composition:Execute(command)
composition:RunScript(filePath)
Use either .lua, .py, .py2 or .py3 as file extension for the corresponding interpreter. Similar to the script menu, .py will execute in the Python interpreter that is installed and set in the preferences. As RunScript is also available in Python you may run .lua scripts from within Python.
Please note that it is not possible to pass return objects from one language to the other.