Run a script
In a test build configured with the bundled Python runtime, choose Scripts > Run trusted Python script… and select a.py file. The host executes the script, validates its result, and creates the declared dialog on the application’s UI thread.
Scripts > VTK mesh stretch example runs the deployed example from System/Scripts/vtk_stretch_dialog.py beside the application executable. This option requires the example file to be present in that development build.
Scripts > Avatar and tools example runs System/Scripts/avatar_tools_dialog.py. It provides body inputs, a supported-tool picker, undo, redo, and refresh. Both examples follow the same test-build gate as the launcher.
The launcher uses the bundled runtime in System/Python beside the executable. Installing Python on your computer does not replace that runtime. The example uses the application’s native VTK implementation; it does not require Python VTK or Qt packages.
Run scripts you trust. The worker has execution and resource limits, but it is not an operating-system security sandbox. Python can access files and network services using its available libraries. API permissions control host operations; they do not confine Python filesystem access.
Imported modules and snapshot data
The launcher injectsarmorsmith and armorsmith.ui. They are available in this launch context, not as a general package you can install or import from a standalone interpreter.
armorsmith.info is a dictionary with these keys:
armorsmith.document is a copied launch snapshot:
Keep identity and revision strings opaque. This Python snapshot contains fewer fields than the C++ snapshot. It does not contain live mesh geometry or application objects. Editing a dictionary changes your copy only.
The script launcher grants document reading, mesh filtering, avatar edits, supported tool activation, history navigation, and UI creation. It does not grant part renaming. Python does not expose live
Session methods as callable functions.
armorsmith.data is a namespace with document, avatar, parts, and workspaces, referring to these copied records. armorsmith.context is the copied context dictionary. armorsmith.document remains available for existing scripts. See For Blender scripters.
UI helper functions
Assign the dialog declaration to the top-level variable
result. These helpers build data; they do not create windows while Python runs. The host validates the declaration after the worker finishes. The contract accepts one result dialog per script run.
Use unique control IDs. For meshes.stretch, pass the mesh picker ID as mesh and the numeric control ID as number. Other supported actions are history.undo, history.redo, and document.refresh. The dialog reference describes validation, limits, and permissions.
0.3 adds armorsmith.ops builders. Pass their result as the action argument to ui.button. They construct declarations; they do not execute operations while Python runs.
The equivalent raw action strings are
avatar.set_measurement, avatar.set_height, and tools.activate. Raw declarations must supply the referenced-control fields described in host actions.
VTK stretch dialog example
Save this asvtk_stretch_dialog.py and launch it from the development build’s Scripts menu:
- Open a costume with an editable, plain workspace mesh that has visible extent along local X. Use a mesh without patterns, skinning, modifiers, or shared geometry.
- Run the script and choose the mesh in Workspace mesh.
- Set X stretch factor to
1.50and click Apply VTK stretch. Its local X extent should increase by 50%. - Click Undo, then Redo, to check the stored geometry change.
- After an edit elsewhere in Armorsmith, click Refresh mesh list before another dialog operation.
Avatar and tools example
Save this asavatar_tools_dialog.py, or use the deployed example in the test build:
- Open a costume with a built-in editable avatar and stop/reset any retargeted animation.
- Run Scripts > Avatar and tools example. Choose a measurement and make a small change within its bounds. Click Set measurement.
- Check the body visually, then use Undo and Redo. Confirm the measurement and body return together.
- Change Height (mm) and click Set height. Confirm the other measurement values and bounds refresh.
- Focus the costume viewport, return to the dialog, and click Refresh. Select Measure or Edit avatar, then click Activate tool and use it in the viewport.
- Edit elsewhere and try an action from the stale dialog. It should request a fresh snapshot. Click Refresh before deciding to apply another edit.
Launcher build switch
The launcher is gated byUSE_FORGECORE_TESTING, the existing test-feature define used by Release_Test_Build. Normal release builds omit the Scripts menu and both example entries. The underlying C++ API remains available to the host.
To expose this menu in a future release without enabling the whole test UI, define ARMORSMITH_ENABLE_SCRIPT_MENU when compiling the common ForgeCore application code and rebuild it. The gate is in PublicApiHost/ScriptMenuBuildGate.h. Rebuild the adapter; changing only the executable’s defines does not change an already-built common library.
