Versions Compared

Key

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

...

Code Block
themeEclipse
languagepython
linenumberstrue
import random

percentVariation = 10
rangeMass        = (currentMass / 100) * (percentVariation / 2)
randomValue randomMass      = random.uniform(-rangerangeMass, rangerangeMass)
newMass          = currentMass + randomValuerandomMass
Info
Please note that the operation above might fail for very small mass settings! 

...

Code Block
themeEclipse
languagepython
linenumberstrue
from time import *
import random

startTime         = clock()
percentVariation  = 10
userSelection     = scene.getSelectedNodes()

for node in userSelection:
    rbdState = node.getParameter("Dynamics")

    if (rbdState != "Active rigid body"):
        node.setParameter("Dynamics", "Active rigid body")
    currentMass = node.getParameter("@ mass")
    rangeMass   = (currentMass / 100) * (percentVariation / 2)
    randomValuerandomMass = random.uniform(-rangeMass, rangeMass)
    newMass     = currentMass + randomValuerandomMass
    node.setParameter("@ mass", newMass)

endTime  = clock()
diffTime = endTime - startTime
 
scene.message("\nProcess finished...\nElapsed time: "+str(diffTime)+" seconds")

...