Scripting and Programming in Katana

Katana utilizes three languages for scripting within the application: Python, Lua, and C++. Each serves a distinct purpose but the language most appropriate for you may vary, depending on what you want to achieve and whether you need to edit the scene graph or scene graph locations.

This page provides an overview of how to get started with scripting and programming in Katana and which language is most appropriate for which tasks.

Python

Python is used widely for rapid application development, especially in the context of APIs to allow users to customize the application. Information about Katana customization can be found in the Katana Developer Guide. For example:

Alternatively, for more information and detailed articles on various Python workflows, visit the Support Portal.

Where fast performance is required, Python isn’t always an ideal choice, partly due to the GIL.

In the context of parameter expressions, a faster alternative to Python expressions is Reference Expressions which can be used for simple expressions that reference nodes or parameters. More information on Reference Expressions, can be found in the Katana Developer Guide.

 

Lua

Lua is used within the OpScript node in Katana. By using OpScript/Lua, it is possible to access the Op API, which is both faster and more powerful than Python. In particular, the OpScript node allows you to modify the structure of the scene graph hierarchy, such as deleting locations, creating new child locations as well as setting and editing attributes.

Lua represents a reasonable balance between fast development turnaround time for developing operations on the scene graph, and fast execution time and stability as part of cooking a scene.

Note:  Lua is also useful for prototyping more complex operations that are planned to be implemented as Op Types later.

In certain situations it may be advisable to implement a custom Op type plug-in instead of using OpScript/Lua. Whether this is of advantage should be determined on a case by case basis as it can depend on the complexity of a project and its assets, the number of operations to be performed or the number of scene graph locations to target. It's advisable to process FX data like particle simulations in Ops/C++, rather than OpScript/Lua.

For an introduction to using OpScript and the Op API, you can look at the OpScript tutorials in available in Katana at:

Help > Example Projects

More information on the Op API, see OpScript Nodes or The Op API. You can also refer to Cook Interface (OpScript) in the Katana Developer Guide.

 

C++

When performance is critical, for example, when working with large data sets, a Lua OpScript can be ported to a C++ Op type plug-in.

Please see the Katana Developer Guide for documentation of the interface. You can also refer to the HelloWorld example Op which is shipped with the Katana source code in the following location:
$KATANA_ROOT/plugins/Src/Ops/HelloWorld

Build instructions can be found here:
$KATANA_ROOT/plugins/Src/README.md

Note:  For more information and further reading on scripting and programming in Katana, refer to the associated article on the Support Portal, Scripting and Programming in Katana.