Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Events Scripts can handle different tasks and therefore it is necessary to distinguish a few types. Within RealFlow there are three fundamental types:

  1. Batch scripts
  2. Simulation Flow scripts (aka "events scripts")
  3. Custom node scripts

Each of these types has its own editor window. Even if the windows appear different, they have some important similarities. The visual appearance of the scripting windows is controlled by RealFlow’s preferences, where you can adjust things like font type, syntax colours and folders for storing your programs:

Menu bar > File > Preferences > Script (Windows/Linux)

Menu bar > RealFlow > Preferences > Script (OS X)

Syntax highlighting is another important similarity. Whenever RealFlow detects an instruction or known function in your code, it will be coloured. For all scripting windows, RealFlow provides auto completion. This function helps you to complete a statement with the help of a drop-down menu. It appears when parts of a command are recognized and allows you to choose the desired function.

"Simulation Flow" scripts are always connected to a certain project and stored directly with the scene. They can also be saved as individual files and used for other scenes, but in this case they normally have to be adapted. Events are start and end of a simulation or the beginning of a new time step or frame. Scripts are not limited to one of these events. You can write one part that is only executed at the beginning of the simulation and another one that is applied at each simulation step. These types of “split” scripts are often used to initialize a scene or reset values to defaults, and then perform the actual calculation. 

Menu Bar > Layout > Simulation Flow (Ctrl + F2)

 

The first impression shows a split window. The upper part consists of a tree with 3 three higher-ranking entries:

  1. SimulationPre
  2. Frames
  3. SimulationPost

...

“Frames” also carries a little “+” or “-” symbol, indicating that this menu can be expanded or collapsed. The branches of the tree are where you can place your own scripts and directly determine when they will be executed. This tree also represents the internal hierarchy:

A. Simulation > B. Frame > C. Step

Simulation events can carry more than one script. It is possible to add one or more scripts for any event that wears a “Pre” or “Post” suffix. The scripts can be appended by choosing the desired event, e.g. "FramesPre", and right-clicking on it. This action opens a context menu with some entries:

...

To run a simulation without a certain script, it is not necessary to delete it. You can just set it to inactive by unticking the appropriate checkbox.

 

RealFlow's tree for events scripts.

 

Once a script has been stored, it can be used again and again. You can also load a script from another source, e.g. RealFlow’s scripting homepage. With “Add Script From File” a script can be imported. Please keep in mind that external scripts usually have to be adjusted to your needs and nodes. A completely new function is the “Add From Plugin” option. With this method it is possible to choose a custom plug-in plugin from the "Command Plugins" manager, where you will find all available plug-insplugins. The “Expand All” button simply expands all branches from the scripts pipeline marked with the “+” symbol.

The lower part of the events window shows a “Master” tab together with a menu bar, consisting of four entries. These menus are exactly the same as described under “Common Settings”. This section was added for compatibility reasons, because Python scripts from RealFlow 4 used a different structure with predefined functions. You can still use the “Master” section, but we recommend to write and organize scripts with the new tools. Next to “Master” there is another tab containing an empty editor. By default it is named “None Selected”, but when you choose a script from the tree, you can edit it there, instead of constantly opening and closing separate windows.

 

Info
You can still use the “Master” section, but we recommend to write and organize scripts with the new tools.


The execution of a simulation events "Simulation Flow" script can be very time consuming, depending on the complexity of your script and the performed calculations. You will also see a significant drop in simulation speed with scripts, mainly with events scripts (Python is single-threaded).

...