Skip to content
Simon Candelaresi edited this page Apr 9, 2020 · 15 revisions

BlenDaViz Wiki

Set Up

BlenDaViz requires Blender version 2.8 or above and is not compatible with any previous version due to syntax changes. It also requires the Python libraries numpy, scipy, eqtools and matplotlib, which can be installed via your package manager or via pip.

Note that the version of the library must correspond to the version of the inbuilt Python of Blender, rather than the one installed on your system. If both match you are lucky and have an easy installation. If not you need to follow some simple steps, as explained below.

After the successful installation of Blender and the required libraries you need to download the BlenDaViz library and can store it wherever on your PC, say ~/libs/blendaviz. You now need to set your PYTHONPATH variable on your system, which can be different depending on what operating system you are using and what shell (bash or tcsh). On any Unix system (Linux, MacOS, BSD) using bash just add this to your ~/.bashrc:

export PYTHONPATH=$PYTHONPATH:~/libs

Once you start Blender, open a Python console in Blender and type import blendaviz as blt and you are good to go.

Install Blender 2.80+ and Libraries Locally

If your already installed Blender and Python libraries work together, there is no need to read this section. If you are trying to use BlenDaViz on a computer that requires a manual installation of Blender and the libraries or if you are on a computer for which you do not have root/admin access follow this guide.

  1. Download and extract/install Blender 2.80+.

  2. Extract the file. There will be an executable within the directory. Let us call this directory blender_dir.

  3. Install the required Python libraries for the correct version. For this you need to verify the version of the inbuilt Python of Blender. You find this in the directory 2.8X/python/bin/ and replace X with the right Blender version. For Blender 2.81 this is python3.7m. Now install the required libraries using pip for the correct Python version:

cd blender_dir/2.8X/python/bin
./python3.7m -m pip install numpy
./python3.7m -m pip install scipy
./python3.7m -m pip install eqtools
./python3.7m -m pip install matplotlib

Usage and Examples

Open Blender and within Blender a Python console. Import BlendaViz and numpy:

import blendaviz as blt
import numpy as np

Marker Plots

In this simple line plot we will create some data and plot them. We will also see how we can manipulate existing plots.

# Create the data.
y = np.linspace(0, 6*np.pi, 20)
x = 2*np.cos(y/2)
z = 2*np.sin(y/2)
# Generate the scatter plot.
pl = blt.plot(x, y, z, marker='cube', radius=0.7)
# Change the color.
pl.color = np.ones([x.shape[0], 4])
pl.color[:, 0]  = np.linspace(0, 1, 20)
pl.color[:, 1] = 0
pl.plot()

For rendering the image we need a camera and lights. A camera should already exist. If not click into the 3d view, press SHIFT + a and select Camera. Now place it at (26.8, 20.2, 25.6) with rotation (47.7, -1, 113). Now place two lights anywhere in the scene, one with rotation (85, 180, 75) and one with rotation (-180, 120, -90). Change the type to Sun and set the strength to 2. Now you can render the scene by pressing F12.

Marker plot

Line Plots

A line plot is very similar to a marker plot. It draws the data points as a line/tube.

import blendaviz as blt
import numpy as np
# Generate the data.
y = np.linspace(0, 6*np.pi, 400)
x = 2*np.cos(y)
z = 2*np.sin(y)
# Generate the line plot.
pl = blt.plot(x, y, z, radius=0.5)

Line plot

Troubleshooting

Clone this wiki locally