Supplementing the Blender simulator with other tools can enable creating animations not otherwise possible. How can another simulator be co-simulated with Blender?
1 Answers
Blender 2.8 can co-simulate with simulation tools that generate FMUs (see https://fmi-standard.org/ ) using the FMPY library. Most versions of Modelica will create FMUs. A complete list of simulation tools that create FMUs is found at https://fmi-standard.org/tools/ .
Installation
To co-simulate with an FMU, the library FMPY (https://github.com/CATIA-Systems/FMPy ) should be installed. This procedure will work on Blender 2.8 and later.
- Using the python version with Blender, at the command prompt enter 'python -m pip -install FMPY'
- Is FMPY installs successfully, the final message should say something like 'Successfully installed ...'
- Verify installation by opening Blender and typing 'import fmpy' into the console. If it successfully imports, then the library was installed.
- Verify an FMU can be imported by downloading an FMU and loading.
- Download 'rectifier.fmu' from https://github.com/modelica/fmi-cross-check/blob/master/fmus/2.0/cs/win32/Dymola/2019FD01/Rectifier/Rectifier.fmu
- Enter the following python commands:
from fmpy import *
fmu = 'path-to-fmu\\rectifier.fmu'
dump(fmu)
- If a summary of the fmu prints out, then the module is working an able to import fmu's.
Usage
To co-simulate, a python script can be used with animation nodes to initialize and co-simulate. The fmu_simulate command can be used to set the state,set inputs, step in time, and get the outputs and new state. See https://github.com/CATIA-Systems/FMPy/blob/master/fmpy/examples/coupled_clutches.py for an example of this command.
- 5,186
- 1
- 30
- 51