-
Notifications
You must be signed in to change notification settings - Fork 8
Installing Blendyn
Blendyn has been ported to Blender 2.80. Blendyn is currently still compatible with Blender versions from 2.50 to 2.79, through the code in the branch blendyn27
.
Be careful though, that only occasional bugfixes will be applied in that branch,
as the main development will be carried out in the devel
and master
branches.
The basic installation of the add-on is very simple. Download the repository as a
.zip
file using the Download ZIP button at the top right of the repository
main page, under the Code menu.
NOTE: please check that the current active branch is "master": that is the one you want to download, unless you are an MBDyn developer or, in general, have access to the bleeding edge MBDyn's source code.
In Blender, go to
Edit
-> Preferences
-> Add-ons
-> Install
(File -> User Preferences -> Add-ons
->Install from File...
for Blender 2.7x)
and locate the .zip
file that you have downloaded. The add-on will be shown
under the Physics
category. You will have to activate it in the usual way,
by clicking on the checkbox on the right.
If, upon the activation of the add-on, complaints that the
numpy
package is not installed, please follow the instructions below to installpip
, if it is not already present in your system, and then installnumpy
with
# pip install numpy
or
# pip3 install numpy
Additionally, for some elements (like beams, for example) to be
visualized correctly, you need to activate the Auto Run Python Scripts
option in the Save & Load
tab of the Blender User Preferences (or
File
tab in Blender 2.7x), as shown in the picture below.
A few optional Python packages are needed to enable some additional features in Blendyn:
- the
netcdf4
package is needed to import MBDyn results in NetCDF format - the
pygal
andcairosvg
packages are needed to enable the plotting of MBDyn output from the Blender UI - the
psutil
package is needed to enable running MBDyn from the Blender UI
Blendyn depends also on numpy
, which should be bundled in recent
Blender versions, but may be missing on some platforms.
In the current version, Blendyn is equipped with an automatic system to check for the
presence of the packages required by the additional features, and install them. The panel
is accessed through the Blendyn addon section in the Edit
-> Preferences
-> Add-ons
Blender menu.
Below the Blendyn info, a Preferences
section, dedicated to optional features, is
displayed:
if the packages required by an additional feature are missing, an Install dependencies
button is displayed at the end of the related block. Clicking on it will result in Blendyn
checking for and, if needed, installing pip
and using it to install the required packages. The latter will be installed in the
modules
folder aside of Blender user addons folder (e.g., for GNU/Linux systems,
/home/user/.config/blender/v.vv/scripts/addons/modules
, where v.vv
is the installed
Blender version).
If the packages are found, the Install dependencies
button is hidden and a checkmark
appears next to the Python packages names.
NOTE 1: Using MBDyn NetCDF output with Blendyn is highly recommended.
NOTE 2: some bugs have been reported using the latest version of Blendyn with Blender 2.76 under Ubuntu. Apparently, the bug is related to Blender code and not Blendyn code, since it doesn't appear in other versions of Blender and neither in the same version on a different platform (our test case was Blender 2.76 on Mac OsX). In this cases, a possible solution is to install a different version of Blender using precompiled binaries available on the Blender website. To use the system standard Python installation with a Blender pre-compiled binary, you can follow these instructions. Be sure to download a version of Blender that is designed to use the same Python version that is available on your system.
WARNING! this section is outdated since August 2020, when the Python packages management system described in the previous section has been introduced, making it much easier to cope with additional Blendyn dependencies. It is left here for legacy, mainly for Blender 2.7x users.
Just install Blender from the repos (This is important, as the Blender version from the repos will work with the system version of Python, and does not come with a bundled python distribution) and install the python packages needed to support the additional features. You can do it with pip, that in turn you can install with
# dnf install python3-pip
For NetCDF support:
# pip install netCDF4
for plotting support:
# pip install pygal cairosvg tinycss lxml cssselect
Notice that NetCDF support is currently required to enable plotting.
Other system packages might be required by pip
during the installation, for example
hdf5-devel
, python3-cffi
, libffi-devel
, netcdf4-python3
. Pay attention
to the error messages, as you should always do :)
The procedure is similar to the Fedora one. Again, this assumes that you have
installed Blender from the distribution repos.
On Ubtuntu 20.04, you can directly install all the required packages from the package manager without resorting to pip using the following command: # apt install python3-netcdf4 python3-pygal python3-cairosvg python3-tinycss python3-lxml python3-cssselect
. Alternatively,
Install pip if it is not installed yet
# apt-get install python3-pip
then install the python packages. For NetCDF
support
# pip3 install netCDF4
You might be warned by pip3
that some required libraries are not installed in
your system (quite probably at least libhdf5-dev
). You can do it in the usual
way with apt-get
or aptitude
.
For plotting
# pip3 install pygal cairosvg tinycss lxml cssselect
Again, NetCDF support is required to enable plotting.
Pip might tell you that some dependencies are not met. For example, it might ask
you to install also libffi
. If that is your case, you can do it in the usual
way with
# apt-get install libffi-dev
Please be aware that I'm not totally sure that the development package is needed
here: pip
might be happy with just the regular libffi
package.
In OpenSuse, the NetCDF packages required to enable NetCDF support to both MBDyn and Blendyn can be installed with1
# apt-get install libnetcdf_c++-devel
# apt-get install netcdf-devel
This is were things get interesting. I'll just give my experience with OsX 10.9.5
and 10.13.6
, Blender 2.76b
and MacPorts
.
Be aware that YMMV, greatly, if you try other combinations.
First install the python34 port and the related pip port:
# port install python34 +readline
# port install py34-pip
the +readline
variant is useful if you plan to also use this python version
interactively from command line, otherwise it can be dropped.
Now you can install the python packages with pip
# pip3.4 install netCDF4 (for NetCDF support)
# pip3.4 install pygal cairosvg tinycss lxml cssselect
Again, the second row is useful only if you want to enable plotting.
Now you have installed everything you need. You need now to make sure that
Blender bundled python distribution can see the packages.
The simplest way is to make a simlink of the site-packages
MacPorts folder to
the one in the Blender application folder:
$ cd /Applications/blender-2.76b-OSX_10.6-x86_64/blender.app/Contents/Resources/2.76/python/lib/python3.4
# ln -s /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages site-packages
The following guide2 will provide help in the installation of both MBDyn and Blendyn in Windows 10/11 operating system, using the Windows Subsystem for Linux feature. It assumes that WSL is installed, so please refer to the linked page on the Microsoft documentation to get started from scratch. This guide also assumes that the distribution installed in the WSL is Ubuntu.
The part related to the MBDyn installation can be used also as a reference for a Blendyn-friendly MBDyn installation in Ubuntu (and most of Debian and Ubuntu based distributions).
Also, please note that in the following guide, as was the case in the other sections
above, commands preceded by #
should be issued with superuser privileges.
This, generally, in the GNU/Linux environment, means that they should be preceded by
a "sudo" statement. Commands preceded by a $
can instead be issued by a normal user.
Open WSL and install the required (first apt install
line) and additional
(second apt install
line) packages for MBDyn:
# apt update
# apt install autoconf libtool make gcc g++ gfortran
# apt install liblapack-dev libnetcdf-dev [ libnetcdf-cxx-legacy-dev | libnetcdf-c++4-dev ]
meaning that you can either install libnetcdf-cxx-legacy-dev
or libnetcdf-c++4-dev
, as
MBDyn now supports both.
Download MBDyn, cloning it from the Gitlab repository (install git if needed before cloning)
$ git clone https://public.gitlab.polimi.it/DAER/mbdyn.git
$ cd mbdyn/
$ git checkout develop
Generate the configure scripts:
$ sh bootstrap.sh
You are now ready to configure, build, and install the MBDyn package:
$ ./configure --enable-netcdf --with-lapack --prefix=/usr/local
$ make -j4
# make install
the choice of changing the prefix to /usr/local
is arbitrary: one can choose
to keep the default prefix /usr/local/mbdyn
and add the /usr/local/mbdyn/bin
directory to the systems' PATH
environment variable (look
here, for example,
for more information).
Head over to the Blender website and download the release that you want, avoiding the 2.8 beta: the Python API of Blender will be changed in version 2.8, and Blendyn has not yet been upgraded to follow suit.
Hereafter, it will be assumed that Blender version 2.79b
has been installed.
Open Blender, open the Python Console and note the Python version that Blender
uses. For the purposes of this guide, we'll suppose it is version 3.5.3
.
Now download Python from the official website,
choosing the version that Blender is using. In our example,
you would choose 3.5.3
.
In the Python setup dialog, select Add Python to environment variables
under
Advanced Options
.
Download and install also GTK3 for Windows, you can find it here.
Once Python has been installed, open a Command Prompt (cmd)
as Administrator
and use pip
to install the additional packages required to run Blendyn with
all features enabled (if you are not interested in plotting, install only the
netCDF4
module):
> pip3 install --upgrade setuptools
> pip3 install numpy netCDF4 pygal cairosvg tinycss lxml cssselect
Now it is time to set up the Python's path in Windows 10 environmental variables. Go to
My Computer -> Properties -> Advanced System Settings -> Environment Variables
Add PYTHON
and PYTHONPATH
environment variables, holding Python's installation
paths. Directories must be separated by a semicolon. For example, for Python 3.5:
C:\Program Files\Python35\
C:\Program Files\Python35\DLLs
C:\Program Files\Python35\include
C:\Program Files\Python35\Lib
C:\Program Files\Python35\libs
C:\Program Files\Python35\Scripts
C:\Program Files\Python35\Tools
C:\Program Files\Python35\tcl
Be aware that these paths can change, based upon the installation settings and
your system's configuration. If you want to find the root directory of Python
after you installed it, just look at the path pointed by the shortcut that can
be found by searching for Python
in the start panel.
Now you can delete the python
folder in the Blender installation directory,
which for Blender 2.79 should be
C:\Program Files\Blender Foundation\Blender\2.79\
Open Blender 2.79, open a Python Console and type the following commands, one after the other:
import netCDF4
import pygal
import cairosvg
import tinycss
import lxml
import cssselect
If they all run smoothly without errors, the Python 3.5 installation and the additional modules have been correctly recognised by Blender.
Download the .zip
from this repo and install the addon following the
instructions at the top of this page.
1: Thanks to Stefano Francesco Pitton for the tip.
2: The original version of this guide was kindly sponsored by Jacopo Surra.