Versions Compared

Key

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

Add the script to Simulation Flow (Ctrl/Cmd + F2) > FramesPost.

The script calculates the average velocities of a scene's active rigid bodies for each frame of a simulation and prints out the result:

Initializing the Objects

Add the script to Simulation Flow (Ctrl/Cmd + F2) > SimulationPre.

Code Block
objects       = scene.getObjects()
activeObjects = []

for entry in objects:
	dynamicsMode = entry.getParameter("Dynamics")
	activeObjects.append(entry)

# The global variable is necessary to transfer the active objects from "SimulationPre" to "FramesPost".
scene.setGlobalVariableValue("activeObjects", activeObjects)

Calculating the Velocity

Add the script to Simulation Flow (Ctrl/Cmd + F2) > FramesPost.

The output is formatted ("%.2f" % averageVelocity) and clips the result to two digits, e.g. 3.67 instead of 3.671472813

...