sourceextensions/blender/lib/Blender.xtl

1⍝│ Blender.xtl -- the facade of the blender extension: Blender 3D in 2⍝│ batch, driven from X_eTaL. A program writes the Python -- a launcher 3⍝│ that runs Blender in the background, and the bpy script Blender runs 4⍝│ inside -- with bl:w_rite!, runs the launcher with bl:r_un! (python3, 5⍝│ with XETAL_BLENDER set to the Blender found), and lists what it made 6⍝│ with bl:f_iles. Paths are under the working directory (or 7⍝│ XETAL_BLENDER_ROOT). 8⍝│ Import: "bl:" u_se< "Blender" 9⍝│ Run with xetal-x (xetal-x --ext DIR puts this directory on XETAL_PATH). 10⍝│ Each signature line is written out by the binding macro (lib/Ffi.xtlm). 11 12"ffi:" u̲se< "Ffi" 13 14⍝│ bl:a_bout @: the extension's name and version. 15"a_bout : unit -> text" ᶠᶠⁱb̲ind< "blender/about"
ᶠᶠⁱb̲ind< expands to
ˡa̲bout ← { @ →
  ⎕N̲GET "ext:blender/about"
}
16⍝│ path bl:w_rite! text: the text into the file (made whole, or not at 17⍝│ all; its directory made); how many bytes. 18"w_rite! : text text -> int" ᶠᶠⁱb̲ind< "blender/write"
ᶠᶠⁱb̲ind< expands to
ˡw̲rite! ← { a b →
  pa ← a ⎕N̲PUT "ext:blender/write?text"
  pb ← b ⎕N̲PUT "ext:blender/write?text"
  f̲loor f̲irst n̲umbers ⎕N̲GET "ext:blender/write"
}
19⍝│ bl:b_lender @: the Blender program found -- BLENDER, the macOS 20⍝│ application, or blender on the PATH -- or "" when there is none. 21"b_lender : unit -> text" ᶠᶠⁱb̲ind< "blender/blender"
ᶠᶠⁱb̲ind< expands to
ˡb̲lender ← { @ →
  ⎕N̲GET "ext:blender/blender"
}
22⍝│ bl:v_ersion @: that Blender's version line ("Blender 5.1.2"), or "". 23"v_ersion : unit -> text" ᶠᶠⁱb̲ind< "blender/version"
ᶠᶠⁱb̲ind< expands to
ˡv̲ersion ← { @ →
  ⎕N̲GET "ext:blender/version"
}
24⍝│ script bl:r_un! args: python3 script args (args split at spaces) from 25⍝│ the working directory -- XETAL_PYTHON, else the active virtual 26⍝│ environment's python3 (VIRTUAL_ENV), else python3 on the PATH -- XETAL_BLENDER set to the Blender found, stopped 27⍝│ after XETAL_BLENDER_TIMEOUT seconds (900 by default); the whole output 28⍝│ goes to the script's .log beside it. "exit N" (or "timeout after S 29⍝│ s"), "errors N" -- the log's Python tracebacks and Blender "Error:" 30⍝│ lines, since a run can fail inside and still exit 0 -- and the log's 31⍝│ last 20 lines. 32"r_un! : text text -> text" ᶠᶠⁱb̲ind< "blender/run"
ᶠᶠⁱb̲ind< expands to
ˡr̲un! ← { a b →
  pa ← a ⎕N̲PUT "ext:blender/run?text"
  pb ← b ⎕N̲PUT "ext:blender/run?text"
  ⎕N̲GET "ext:blender/run"
}
33⍝│ bl:r_ead path: a file's text (a small one a run wrote: a report). 34"r_ead : text -> text" ᶠᶠⁱb̲ind< "blender/read"
ᶠᶠⁱb̲ind< expands to
ˡr̲ead ← { a →
  pa ← a ⎕N̲PUT "ext:blender/read?text"
  ⎕N̲GET "ext:blender/read"
}
35⍝│ bl:f_iles dir: the files under dir, one a line, "bytes path", sorted 36⍝│ by path. 37"f_iles : text -> text" ᶠᶠⁱb̲ind< "blender/files"
ᶠᶠⁱb̲ind< expands to
ˡf̲iles ← { a →
  pa ← a ⎕N̲PUT "ext:blender/files?text"
  ⎕N̲GET "ext:blender/files"
}
38 39⍝│ The native package behind these functions. 40ˡpackage ← "blender"