Difference between revisions of "Maya tmp"
Jump to navigation
Jump to search
| Line 50: | Line 50: | ||
#On change si besoin les valeurs par defaut avant d'executer la fonction | #On change si besoin les valeurs par defaut avant d'executer la fonction | ||
randomize(minValue=4, maxValue=20) | randomize(minValue=4, maxValue=20) | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | === Maya Mel - Replace path - getAttr/setAttr=== | ||
| + | <pre> | ||
| + | for ( $object in `ls -sl -l` ) { | ||
| + | $path = getAttr ($object+".filePrefix"); | ||
| + | setAttr -type "string" ($object+".filePrefix") ($path+"yo"); | ||
| + | } | ||
| + | |||
| + | for ( $object in `ls -sl -l` ) { | ||
| + | setAttr -type "string" ($object+".filePrefix") ("//blabla/bla.abc"); | ||
| + | } | ||
</pre> | </pre> | ||
Revision as of 14:54, 12 December 2019
Contents
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))
Maya Python - Randomize translate of selection #2
#La meme chose en utilisant une fonction
from maya import cmds
import random
objList = cmds.ls(selection=True)
print objList
#On definit la fonction
def randomize(minValue=0, maxValue=5):
for obj in objList:
cmds.setAttr(obj+'.translateX', random.randint(minValue, maxValue))
cmds.setAttr(obj+'.translateY', random.randint(minValue, maxValue))
cmds.setAttr(obj+'.translateZ', random.randint(minValue, maxValue))
#On change si besoin les valeurs par defaut avant d'executer la fonction
randomize(minValue=4, maxValue=20)
Maya Mel - Replace path - getAttr/setAttr
for ( $object in `ls -sl -l` ) {
$path = getAttr ($object+".filePrefix");
setAttr -type "string" ($object+".filePrefix") ($path+"yo");
}
for ( $object in `ls -sl -l` ) {
setAttr -type "string" ($object+".filePrefix") ("//blabla/bla.abc");
}