programextensions/blender/demos/hello.xtl

Blender, 1: X_eTaL runs Blender. The program writes two Python files -- the launcher, which runs Blender in the background (with its factory settings, so the run never depends on yours), and the script Blender runs inside, which writes a report -- then runs the launcher with python3 and reads the report back. The chain: X_eTaL, the extension, python3, Blender, Python inside Blender. Run: just demo blender hello

source · imports bl: extensions/blender/lib/Blender.xtl

launcher : Char

value · line 14

the launcher: python3 run.py SCRIPT ARGS runs Blender in the background on SCRIPT, passing ARGS after "--"; Blender's exit status is its own (a Python error inside makes it 1)

launcher ← "import os, subprocess, sys\nblender = os.environ.get(\"XETAL_BLENDER\") or sys.exit(\"no Blender found\")\nrun = [blender, \"--background\", \"--factory-startup\", \"--python-exit-code\", \"1\", \"--python\", sys.argv[1], \"--\"] + sys.argv[2:]\nsys.exit(subprocess.run(run).returncode)\n"
Used in: _

inside : Char

value · line 18

the script Blender runs: the objects of the scene it starts with, written to the file named after "--"

inside ← "import bpy, sys\nout = sys.argv[sys.argv.index(\"--\") + 1]\nnames = sorted(o.name for o in bpy.data.objects)\nopen(out, \"w\").write(\"objects: \" + \" \".join(names) + \"\\n\")\n"
Used in: _

_ : Int

function · line 22
_ ← "work/hello/run.py" ᵇˡw̲rite! launcher

_ : Int

function · line 23
_ ← "work/hello/hello.py" ᵇˡw̲rite! inside

r : Char

value · line 24
r ← "work/hello/run.py" ᵇˡr̲un! "work/hello/hello.py work/hello/report.txt"
Used in: lines

lines : Box Char

value · line 26
lines ← (n̲ot r = f̲irst "\n") p̲artition r