9
SCRIPTING GUIDE
1
FUSION SCRIPTING GUIDE AND REFERENCE MANUAL
What is scripting? Scripting is interpreting the specific programming language—in theory—line
by line or in the form of compiled bytecode as opposed to executing precompiled machine code
directly. Without going too deep into implementation details, it can be concluded that due to its
nature, a complex application like Fusion can act as host and provide access to its functionality
through a dedicated scripting API. The scripting environment wraps the underlying API and is less
likely to crash the whole application if third-party code is defective. Code can be changed on the fly
without restarting the host application. Additionally, a garbage collector does most of the memory
management in common scripting environments. All this results in slower evaluation compared
to native compiled code, but the performance is still beyond what can be done by a user with
the regular graphical user interface. The JustInTime (JIT) flavor of Lua that is utilized in Fusion is
especially known to perform almost as fast as native code in many cases.
Ultimately, scripting allows for any programmer to mix the language features and libraries of the
scripting language with the functionality of the host application. This allows an integration of third-
party data or applications.
Let’s examine practical uses of scripting within Fusion by example. Scripting in production may
help with:
> Automation: For example, read all media files from a given folder,
for each of these, load them into a composition, add a watermark,
scale them, and render them to a specific location.
> Repetitive tasks: For example find all savers in a composition
and set their state to pass-through.
> Maintaining conventions: For example making sure the paths of the savers always
point at a specific location on the server, and follow a specific naming convention.
> Tasks prone to human error: For example, verify that certain settings
are set before sending a composition to rendering.
> Extending core features in the application: For example, importing
animation data from a third-party application.
> Behavior that needs customization for specific pipeline: For example,
override what happens when certain events occur. It may enforce
certain tools to show up when a specific tool was created.
> Communication with a third-party application: For example, not only
exchange data but also share events. When a specific pipeline tool
triggers to create a shot, create the corresponding composition.
These are just examples of common applications. Some scripts may require an interface in order to
adapt its behavior to a particular need. This may be a configuration file or information derived from
the applications state (maybe the current selected tool in the composition). But in many cases, a
Introduction