BlenderService
Run Python inside Blender from your program, with no window: hand it input, follow what it prints and get its result back.
Each job gets its own temporary folder and a fresh Blender started in the background with factory settings, so your preferences, startup file and own scripts stay out of it. The script reads INPUT, sets RESULT and may call progress(stage, done, total). RunHeadlessAsync waits for the end; StartHeadlessAsync gives a BlenderJob to watch. A script that raises comes back with its traceback and exit code 1.
A service: write use BlenderService.
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| ExePath | string | "" | The blender.exe that jobs run, by default the newest Blender installed in the standard folder, found when the service starts. |
| Version | string | read-only | What ExePath prints for --version, such as 5.1.1; empty until the first job runs. |
| TempFolder | string | "" | Where job folders are made; empty means a ShotBlender folder in the system's temp folder, chosen at the first job. |
| KeepJobFolders | boolean | false | Keeps each job's folder (job.py, script.py, input.json, result.json) after it ends, for debugging a script. |
Methods
| Name | Arguments | Returns | Description |
|---|---|---|---|
| RunHeadlessAsync yields | (options: HeadlessOptions) | (BlenderResult?, string?) | Waits for Python source to run in a headless Blender, stopped at Timeout (600 s); a failure gives why, plus the result when Blender ran. |
| StartHeadlessAsync yields | (options: HeadlessOptions) | (BlenderJob?, string?) | Starts the same job and gives its BlenderJob without waiting for the end; connect to Line and Progress before your code yields. |
| RunScriptAsync yields | (script: string, options: { Scene: string?, Input: any?, Timeout: number?, Version: string? }?) | (BlenderResult?, string?) | Waits for a script to run with INPUT set to Input, on an optional Scene .blend; its RESULT comes back as Result. |
From ShotInstance 33
ClassNameNameParentAncestryChangedAttributeChangedChangedChildAddedChildRemovedDestroyingAddTagClearAllChildrenCloneDestroyFindFirstAncestorFindFirstAncestorOfClassFindFirstAncestorWhichIsAFindFirstChildFindFirstChildOfClassFindFirstChildWhichIsAGetAttributeGetAttributeChangedSignalGetAttributesGetChildrenGetDescendantsGetFullNameGetPropertyChangedSignalGetTagsHasTagIsAIsAncestorOfIsDescendantOfRemoveTagSetAttribute
