This script provides an automated way to generate procedural tree models using the tree-gen GitHub repository, which is originally a Blender GUI add-on. Instead of manually interacting with the Blender interface, this script enables command-line control using Python.
Download and install the latest version of Blender from the official site: https://www.blender.org/download/
Make sure blender is accessible from your terminal. If not, add it to your system PATH.
- Download the latest
.ziprelease from the tree-gen GitHub Releases page. - Open Blender GUI.
- Go to
Edit→Preferences→Add-ons. - Click
Install...and select the.zipfile. - Enable the checkbox for
tree-gen.
You can now run the script from the command line without launching the Blender GUI:
blender --background --python auto_gen_tree.py -- \
--tree_type tree-gen.parametric.tree_params.quaking_aspen \
--output_dir ./outputs \
--num_trees 3| Argument | Type | Default | Description |
|---|---|---|---|
--tree_type |
string | tree-gen.parametric.tree_params.quaking_aspen |
The preset ID of the tree to generate (must match an enabled preset from the add-on). |
--output_dir |
string | outputs |
Directory to save the generated .glb files. |
--num_trees |
int | 1 |
Number of trees to generate. Each will use a different random seed. |
The script will generate .glb (GLTF binary) files named like:
outputs/tree_000.glb
outputs/tree_001.glb
...
These files can be opened with any GLB viewer or imported into 3D engines like Unity, Unreal, or Three.js.
Example generation result with default quaking_aspen parameters:
- This script must be run inside Blender using
--python, not as a regular Python script. - Ensure the
tree_typestring matches a valid preset exposed by the add-on (check in the Blender UI or console). - Blender may take a few seconds per tree due to procedural geometry generation.
- Find or assign a default material so that the generated plant looks visually reasonable (e.g., green leaves, brown stems).
