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.

ShotInstanceservicenot creatableMeshes and 3D

A service: write use BlenderService.

Properties

NameTypeDefaultDescription
ExePathstring""The blender.exe that jobs run, by default the newest Blender installed in the standard folder, found when the service starts.
Versionstringread-onlyWhat ExePath prints for --version, such as 5.1.1; empty until the first job runs.
TempFolderstring""Where job folders are made; empty means a ShotBlender folder in the system's temp folder, chosen at the first job.
KeepJobFoldersbooleanfalseKeeps each job's folder (job.py, script.py, input.json, result.json) after it ends, for debugging a script.

Methods

NameArgumentsReturnsDescription
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