Batch Script

Batch scripts are normally used to complete repetitive tasks, for example parameter changes, import of objects, applying colours, normalizing channels, object creation and manipulation, and so on. All these tasks do not need a simulation and they can be executed “offline”.

 

 

You can read more about RealFlow's different script types under “Adding Python Scripts”.

Quick Start

The “Batch Script” panel can be found in RealFlow's “Layout” menu. What you see is just an empty editor and here, a script is added, e.g.

 

scene.addSphere(4)
scene.message("A sphere has been added to the scene.")

 

Now execute the program with Script > Run. The sphere you get has a higher resolution as RealFlow's standard sphere node: the “4” argument is responsible for this high-res version. In the “Messages” window you will find the text from the scene.message command.

In order to add five spheres, a loop is required:

  • Remove the previous script with Script > Clear.
  • Please mind the lading tabs, because otherwise you will receive a syntax error.
  • Possible errors can be detected with Script > Syntax.

 

numberOfSpheres = 5
for i in range(0, numberOfSpheres):
	scene.addSphere(4)
scene.message(str(numberOfSpheres)+" spheres have been added to the scene.")

 

When you alter the value of the “numberOfSpheres” variable you will get more spheres, and the output in the “Messages” window will change as well.

Batch Script Menu

The great majority of menu entries is self-explaining and can be found in many other applications. Therefore we want to focus on the most important commands.

 

 

File

Load and save your scripts; open the → scripting preferences.

 

Edit

Copy, paste, and cut parts of the script, perform find and replace actions, and undo/redo your actions.

Shift Right Text | Shift Left Text

Leading tabs and spaces play an important role with Python. These functions allow you to create tabs for a selected text block.

 

Script

Clear

Removes the entire script from the editor.

Show suggestions

Select a coloured RealFlow Python command and click on this menu entry to get the complete syntax structure.

Run

Execute the script.

Check Syntax

This function performs an error check. Errors are displayed in the editor and the “Messages” panel. Scripts with syntax errors will not be executed.

 

Help

Here you will find a link to RealFlow's internal scripting reference – a compilation of all available commands. It is also possible to request help for a selected coloured RealFlow Python command.