Working in Blender
COMPAS packages can be installed in Blender and used in Blender scripts.
Blender is also a supported visualisation backend for COMPAS scenes,
and compas_blender
provides functionality for converting COMPAS objects to Blender objects, and vice versa.
Note
These instructions are for the latest version of Blender (4.0) and for the current LTS versions (3.3 and 3.6).
Warning
The installation procedure is a work in progress. It has currently only been tested on macOS, and may change in the future.
Installation
The installation of COMPAS in Blender can be done in two ways:
by installing COMPAS in Blender’s Python environment using
pip
, orby using the
compas_blender.install
command.
Using pip
(recommended)
Blender comes with its own Python installation.
This procedure simply uses that Python installation and associated pip
to install COMPAS.
The location of the executable is different on different platforms.
The default locations are:
Windows:
C:\Program Files\Blender Foundation\Blender 4.0\4.0\python\bin\python.exe
macOS:
/Applications/Blender.app/Contents/Resources/4.0/python/bin/python3.10
Linux:
/usr/share/blender/4.0/python/bin/python3.10
(i think :)
Note
If you already have an installation of COMPAS on your system, you can try finding the Rhino 8 Python executable by running the following in a terminal or command prompt:
python -m compas_rhino.print_python_path
Install from PyPI
For example on Mac:
$ /Applications/Blender.app/Contents/Resources/4.0/python/bin/python3.10 -m pip install compas
Install from Source
$ cd path/to/compas
$ /Applications/Blender.app/Contents/Resources/4.0/python/bin/python3.10 -m pip install -e .
Using compas_blender.install
Warning
This procedure will not install any of the dependencies required by COMPAS. They have to already be present in the Blender Python environment.
The compas_blender.install
command installs COMPAS in Blender’s Python site-packages
folder
by creating symlinks to COMPAS packages installed in an existing (conda
) environment.
Therefore, before running the command below, you should activate the environment in which you have installed COMPAS.
$ python -m compas_blender.install
Optionally, you can specify the version of Blender using the -v
flag.
$ python -m compas_blender.install -v 4.0
To remove all previously installed symlinks before installing new ones, use the --clean
flag.
$ python -m compas_blender.install --clean
Verification
To test if the installation was successful, you can run the following on the Blender command line.
>>> import compas
>>> print(compas.__version__)
'2.0.0'
Visualisation
Visualisation of COMPAS objects in Blender is handled using viualisation scenes. For more information on visualisation scenes, see Visualisation.
import compas
from compas.datastructures import Mesh
from compas.scene import Scene
mesh = Mesh.from_obj(compas.get('tubemesh.obj'))
scene = Scene()
scene.clear()
scene.add(mesh)
scene.draw()
Conversions
More info coming soon…
import compas
from compas.datastructures import Mesh
from compas_blender import conversions
mesh = Mesh.from_obj(compas.get('tubemesh.obj'))
blender_mesh = conversions.mesh_to_blender(mesh)
mesh = conversions.mesh_to_compas(blender_mesh)