Difference between revisions of "Maya tmp"

From Antoine Vienne | Wiki
Jump to navigation Jump to search
(Maya Python - Randomize selection)
Line 15: Line 15:
 
</pre>
 
</pre>
  
=== Maya Python - Randomize translate of selection ===
+
=== Maya Python - Randomize translate of selection #1===
 
<pre>
 
<pre>
 
from maya import cmds
 
from maya import cmds

Revision as of 02:48, 4 November 2019

Maya tmp Scripts

Maya Python - Create object & Randomize Translate

from maya import cmds
import random

numObjects = 4

for n in range(numObjects):
    obj = cmds.polyCube()
    cmds.setAttr(obj[0]+'.translateX', random.randint(0, 5))
    cmds.setAttr(obj[0]+'.translateY', random.randint(0, 5))
    cmds.setAttr(obj[0]+'.translateZ', random.randint(0, 5))

Maya Python - Randomize translate of selection #1

from maya import cmds
import random

objList = cmds.ls(selection=True)

print objList

for obj in objList:
    cmds.setAttr(obj+'.translateX', random.randint(0, 5))
    cmds.setAttr(obj+'.translateY', random.randint(0, 5))
    cmds.setAttr(obj+'.translateZ', random.randint(0, 5))