from time import *
import random
startTime = clock()
percentVariation = 10
userSelection = scene.getSelectedNodes()
for node in userSelection:
rbdState = node.getParameter("Dynamics")
if (rbdState != "RigidActive rigid body"):
node.setParameter("Dynamics", "RigidActive rigid body")
currentMass = node.getParameter("@ mass")
range = (currentMass / 100) * (percentVariation / 2)
randomValue = random.uniform(-range, range)
newMass = currentMass + randomValue
node.setParameter("@ mass", newMass)
endTime = clock()
diffTime = endTime - startTime
scene.message("\nProcess finshed...\nElapsed time: "+str(diffTime)+" seconds") |