Looping is the most important concept with RealFlow scripts, because this technique makes it possible to address individual particles, objects, simulation nodes, parameters, vertices, etc. Furthermore it is possible to count things, create indices, and many more
To do all these things RealFlow/Python offers several methods:
for ... in
This construction is required if you want to loop through individual particles, nodes, vertices. In common terms: list elements. The notation is basically always the same, and only the type of scene element changes. Here are three examples:
Scene Nodes
Here is a loop for all nodes in a scene. There is no differentiation between domains, emitters, objects, daemons, etc.:
...
Here is a loop for all nodes in a scene. The same principle is valid for daemons, domains, splines, cameras (scene.getDaemons(), scene.get_DY_Domains(), scene.getSplines(), scene.getCameras()
)., and so on:
Code Block |
---|
# Mind the leading spaces. Without them you will get syntax errors! allSceneObjects = scene.getObjects() for singleObject in allSceneObjects do something with singleObject, e.g. activate its rigid body dynamics feature |
...