Difference between revisions of "Maya tmp"
Jump to navigation
Jump to search
(Created page with "=Maya tmp Scripts= === Maya Python - Random Translate === <pre> from maya import cmds import random numObjects = 4 for n in range(numObjects): obj = cmds.polyCube()...") |
|||
Line 12: | Line 12: | ||
cmds.setAttr(obj[0]+'.translateY', random.randint(0, 5)) | cmds.setAttr(obj[0]+'.translateY', random.randint(0, 5)) | ||
cmds.setAttr(obj[0]+'.translateZ', random.randint(0, 5)) | cmds.setAttr(obj[0]+'.translateZ', random.randint(0, 5)) | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | === Maya Python - Randomize selection === | ||
+ | <pre> | ||
+ | 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)) | ||
</pre> | </pre> |
Revision as of 02:45, 4 November 2019
Maya tmp Scripts
Maya Python - Random 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 selection
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))