Versions Compared

Key

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

In the example below, only the first 100 particles names of a Dyverso domainscene's total number of particles are used:

dyversoDomain = scene.get_DY_Domain("DY_Domain01")

dyversoDomainParticles = dyversoDomain.getParticles()

start = 0; stop = 100

for counter in range(start, stop):first 10 objects are being printed to RealFlow's "Messages" panel. There must be at least 10 objects, because otherwise you will get a syntax error!

The counter variable is constantly updated and used as an index to identify elements in the sceneAllObjects list:

Code Block
# Mind the leading spaces, because otherwise you will get syntax errors!
sceneAllObjects = scene.getObjects()
numberOfObjects = 10
 
for counter in range(0, numberOfObjects):
	currentObject = sceneAllObjects[counter]
	nameObject    = currentObject.getName()
	scene.message(nameObject)

 

The next batch script adds all numbers from 0 to 100. The result variable will not be overwritten because of the += operator, but the new number will be added to the already existing result.

To get a correct output it is necessary to define the range from 0 to 101.

Code Block
# Mind the leading spaces, because otherwise you will get syntax errors!
# Initialize the result variable
result = 0
 
for number in range(0,101):
	result += number
 
# Convert the number (integer) to a string
scene.message(str(result))