Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

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:

Scene Nodes

Here is a loop for all nodes in a scene. There is no differentiation between domains, emitters, objects, daemons, etc.:

# Mind the leading spaces. Without them you will get syntax errors!
allSceneNodes = scene.getNodes()
for singleNode in allSceneNodes:
	do something with singleNode, e.g. change one or more parameters
Scene Objects

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()).

# 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 property
Dyverso Particles

Here is a loop for a dyverso domain's ("DY_Domain01") particles. The same principle is valid for Hybrido particles and standard particle emitters:

#Mind the leading spaces. Without them you will get syntax errors!
dyversoDomain          = scene.get_DY_Domain("DY_Domain01")
dyversoDomainParticles = dyversoDomain.getParticles()
for singleParticle in dyversoDomainParticles:
	do something with singleParticle, e.g. get its age and delete it after a certain time

for .. in range(start, stop)

This type of loop is used if you want to specify a certain range.

  • No labels