/blender-clj

Scripting blender with clojure

Primary LanguageClojure

Description

This project uses libpython-clj and a custom build of blender as a python module, to be able to load it in my clojure repl and script it with the GUI visible, all from clojure.

Motivation

I want to script blender with clojure from cider/emacs, or CLI, etc. I want the GUI to be visible.

Screenshot

screenshot.png

Procedure

We need blender to be built as the python module “bpy.so”, but patched to run the GUI in the foreground.

The build has been tested on:

  • Fedora 31 (python 3.7.7, blender 2.83)

Building

“bpy.so” can be built from the patched blender source as follows:

./build-blender-fedora.sh

See https://wiki.blender.org/wiki/Building_Blender/Linux/Fedora for more details regarding dependencies.

Demo

After building, open a clojure repl with the following command:

./build-blender-fedora.sh repl

Run the demo:

(require 'blender-clj.examples.cube)

(blender-clj.examples.cube/demo)

Alternatively, a repl can be loaded as follows, where BPY_BIN_PATH is the directory where bpy.so can be found.

BPY_BIN_PATH=vendor/blender-git/build_linux/bin clj -r