Scripting with the Python Console
Ornatrix App includes an interactive Python console for inspecting your groom, automating repetitive tasks, and driving the application from scripts. It doubles as a live command listener: a command line at the bottom of the Console lets you type Python and run it against the running application, so anything you can do by hand through the interface has, in most cases, a scripting equivalent. This makes the console useful both for one-off operations and for building reusable tools.
Using the console
The Console has a command line marked with a ">>>" prompt at the bottom. Type a Python expression or statement there and press Enter to run it. The command and its result are echoed into the console above, exactly as in a normal interactive Python session:
- An expression (for example
2 + 2orapp.Scene.get_instance().has_groom()) is evaluated and its result is printed. - A statement (for example an assignment, an
import, or a multi-line block) is executed, with anything it prints captured and shown.
The interpreter keeps a single, persistent namespace, so names you define in one command remain available in later commands. The Ornatrix modules are already imported for you under short names, so you can use them immediately without any import line:
app- the application module (scene, views, actions, directory manager).ox- the core Ornatrix module.groom- the groom graph module (objects, operators, connections).
Use the Up and Down arrow keys to recall previously entered commands from the command history.
Auto-complete
As you type, the console shows an auto-complete popup with matching names, similar to code completion in a code editor. For a dotted expression such as app.Scene. the candidates are the real attributes and methods of that object, resolved against the live application, so the suggestions always reflect what is actually available. For a plain word the candidates are names in the current namespace together with Python built-ins and keywords.
- Press Tab to accept the highlighted candidate.
- Use the Up and Down arrow keys to move through the list while the popup is open.
- Click a candidate to insert it.
- Keep typing to narrow the list, or press Escape to dismiss it.
Completion never runs your code: it only inspects plain names and attributes, so it will not trigger side effects while you type.
Output and errors
Whatever a command prints, along with the value of an evaluated expression, is added to the console as ordinary output. If a command raises an error, the console shows a single concise line (the final line of the Python traceback, for example NameError: name 'foo' is not defined) so the log stays readable. The full traceback is still available: hover over the error line to see it in a tooltip, and it is included when you copy the line. An error never interrupts the application; the interpreter keeps running and you can continue entering commands.
What you can script
The application exposes its scene and commands to Python through the app module. From a script you can, for example, query the current scene, access the selected geometry, add and configure operators, and trigger actions. Many of the App's own menu commands are themselves defined as Python actions, which means the same calls are available to you.
A few illustrative entry points:
- The current scene is reached through
app.Scene.get_instance(). - External file paths are managed through
app.get_directory_manager(). See Managing External File Paths. - A line of Python can be run through the console programmatically with
app.execute_console_command("..."), which returns the captured output. Auto-complete candidates are available throughapp.get_console_completions("...").
Automating grooms
Because operators and their parameters are scriptable, you can build a groom entirely in Python, or apply the same series of steps to many assets in turn. This is the basis for batch processing and for sharing grooming recipes that go beyond a single saved groom.
Related
- For the interactive, hand-driven equivalent of building a groom, see The Operator Stack.
- For keyboard-driven commands, see Keyboard Shortcuts.


