Blenderless is the Python package for easy headless rendering using Blender.
While Blender is a fantastic open-source 3D modeling software which can be run from the command line, there are still some inconveniences when rendering from a headless server.
Furthermore, the bpy interface has a steep learning curve.
This package is meant to overcome these issues in a easy-to-use manner.
Example use-cases:
- Generating thumbnails or previews from 3D files.
- Batch generation of views from 3D files.
- Automatic generation of compositions of a set of meshes into a single scene
- Converting meshes and labels into .blend files
- Export GIF animations of a camera looping around an object.
You can find basic examples in the unit tests.
The blenderless package can be loaded as a module. The main functionality is exposed using the Blenderless class.
from blenderless import Blenderless
# Set the following property if you want to export the generated blender workspace.
Blenderless.export_blend_path = 'export.blend'
# Render single STL file
path_to_foo_png = Blenderless.render('meshpath.stl', dest_path=None, azimuth=45, elevation=30, theta=0)
# Render from config, note that objects and cameras are defined within the YAML config.
path_to_foo_png = Blenderless.render_from_config('config.yml', dest_path=None)
# Render GIF animation, note that azimuth is defined by number of frames.
path_to_foo_gif = Blenderless.gif(cls, mesh_path, dest_path=None, elevation=30, theta=0, frames=60, duration=2)Render geometry file to image
bazel run //blenderless -- image /path/to/foo.stl /path/to/output.png
bazel run //blenderless -- --export-blend-path /path/to/export.blend image /path/to/foo.stl /path/to/output.png # If .blend needs to be exported