Scripting

Glaxnimate provides an extensive scripting interface.

See full API Reference page to see all the available modules, classes, and functions.

There are also some useful examples that walk you through a few features.

Script Console

You can use the Script Console to test some snippets and modify the current document.

Here you can access the glaxnimate module and you have the global objects window and document defined.

The console has a button to reload the script module, this means that if you make changes to a python module / script and want the change to take effect, you can click it and you'll see the up to date modules (instead of the version previously cached by Python).

This also affects modules loaded for plugins.

Plugins

You can write plugins to perform common actions, add support for more file formats, and more.

See Plugins for a full description of the structure of a plugin.

If you are developing a plugin, the easiest way to reload the modules when you make changes, is to click on Reload Script Modules in the script console.

As a Python module

Glaxnimate is also available as a mode (you can download it from PyPI).

It provides a similar functionality as the script console but you can call it from python scripts, without the need of a GUI.

Some functionality needs a Glaxnimate environment to run but that's easy to set up:


import glaxnimate

# Set up environment
with glaxnimate.environment.Headless():
    # Create a document object
    document = glaxnimate.model.Document("")

    # Load a file
    with open("MyFile.rawr", "rb") as input_file:
        glaxnimate.io.registry.from_extension("rawr").load(document, input_file)

    # ...

    # Write a file
    with open("MyFile.json", "rb") as output_file:
        output_file.write(glaxnimate.io.registry.from_extension("json").save(document))