Here you find a wide variety of ready-to-use, and fully commented Python scripts for RealFlow.
In most cases, the scripts can be copied and pasted to RealFlow's scripting editor, but you have to make adjustments and changes to adapt a script to your scene:
Node Names
The names of the nodes (domains, objects, daemons, etc.) have to be exactly the same in the scene and the script. If the names differ you will get errors and the script cannot be executed, e.g.
scene.getObject("Sphere01")
requires a polygon object with the name "Sphere01
".scene.get_DY_Domain("DY_Domain02")
requires a Dyverso domain with the name "DY_Domain02
".
If you change a node's name in the scene, the appropriate name has to be applied to the script as well, and vice versa.
Indents and Leading Spaces
Python scripts require a certain formatting and this is mandatory. The presented scripts are pre-formatted have leading spaces and indents:
- The indents and tabs in your script must be exactly the same as in the examples shown here.
- Whenever you see a colon (:) followed by a line break you have to insert an indent in the form of a tab.
- Missing or false indents are the most common source of syntax errors.
Version-Specific Differences
All scripts, shown here, have been developed on and for RealFlow 10. There are version-specific differences such as
- Associated parameter names in RealFlow do not use the
@
prefix as in previous versions - The old
scene.getEmitter("emitter_name")
notation is no longer valid (since RealFlow 2013). - Very old scripts with "
def onFramesPost()
" or "def onSimulationPre()
", etc. should be adapted to RealFlow's "Simulation Flow" scripting workflow.
Modules
In some scripts you will see import
commands followed by math
or random
. These, so-called modules, are external extensions and they are part of RealFlow's Python distribution. This means they are pre-installed.
- If you should get errors, telling you that a module is missing we recommend reinstalling RealFlow.
- There can also be conflicts between different Python installations.
- It is possible to install modules manually and there are hundreds of free additions available, but bear in mind that many some require other modules as dependencies.
- Especially with 3rd party scripts you have to make sure that all modules are available. Common modules are NumPy, SciPy, PyOpenGL, or PyGame. It depends on your Python version, distribution, or operating system if these modules are installed by default!