Skip to content

Instantly share code, notes, and snippets.

cmds.polyColorPerVertex ( r =0.0 , g =1.0 , b =0.0 , a =1, cdo =True )
@manhha00
manhha00 / changeColorAttr.py
Created July 28, 2017 15:10
scripJob - scriptNode: create a expression, add an attr to object, change color via fun in expression
myCode = '''
from maya import cmds
def test():
print 'ok'
sel = cmds.ls(sl=True)
obj_attr = '%s.color' % sel[0]
colorNum = cmds.getAttr( obj_attr )
if cmds.getAttr(obj_attr) == 0 :
cmds.polyColorPerVertex(r=0.0,g=1.0,b=0.0,a=1,cdo=True)
window;
columnLayout;
string $selObj[] = `ls -sl` ;
textFieldButtonGrp -text $selObj[0] -buttonLabel "Button" -buttonCommand "objectName" selectedObject;
proc objectName(){
string $selObj[] = `ls -sl` ;
textFieldButtonGrp -e -text $selObj[0] -buttonLabel "Button" -buttonCommand "objectName" selectedObject;
}
showWindow;
@manhha00
manhha00 / stop loopOut
Created November 8, 2017 03:18
after effect - stop loopOut on in mark point
loopOut(type = "cycle", numKeyframes = 0)
stop = marker.key(marker.numKeys).time;
loopDur = key(numKeys).time;
if (time > stop){
stop%loopDur;
}else{
loopOut();
}
@manhha00
manhha00 / remove pre name in mel
Created November 16, 2017 12:02
remove pre name in mel
namespace -mv "insert_namespace_here" ":" -force;
@manhha00
manhha00 / change textField when selected something
Last active November 28, 2017 02:16
maya - mel - change textField when selected something
proc updateUi()
{
string $sld[] = (`ls -sl`);
print $sld[0];
textField -edit -tx $sld tfd ;
}
scriptJob -ct "SomethingSelected" "updateUi()";
@manhha00
manhha00 / python - Running script from maya button
Created November 27, 2017 02:47
python - Running script from maya button
import maya.cmds as cmds
class UI(object):
def __init__(self):
if cmds.window('myWindow', exists=True):
cmds.deleteUI("myWindow")
window = cmds.window('myWindow', title='MyWindow')
cmds.columnLayout()
cmds.button(l='myButton', c=self.btnCmd)
@manhha00
manhha00 / maya - python - functools
Created November 27, 2017 03:11
maya - python - functools
#Following is the exercise, function provided:
from functools import partial
def func(u,v,w,x):
return u + v + w + x
#Enter your code here to create and print with your partial function
dbl = partial(func, 4 , 4 , 4)
print (dbl(4))
@manhha00
manhha00 / maya - python - expresison - scriptJob change color
Created November 28, 2017 02:14
maya - python - expresison - scriptJob change color when change attribute
import maya.cmds as cmds
def colorChange() :
if cmds.getAttr('pSphere1.color')==0 : # attribut a Blue
cmds.polyColorPerVertex(r=.159,g=.3811,b=.86,a=1,cdo=True)
elif cmds.getAttr('pSphere1.color')==1 : # attribut a Red
cmds.polyColorPerVertex(r=.86,g=.159,b=.3811,a=1,cdo=True)
elif cmds.getAttr('pSphere1.color')==2 : # attribut a Green
cmds.polyColorPerVertex(r=.3811,g=.86,b=.159,a=1,cdo=True)
@manhha00
manhha00 / maya - mel - xray toggle
Created December 1, 2017 14:59
maya - mel - xray toggle
//Toggle Viewport X-Ray:
$currentPanel = `getPanel -withFocus`;
string $panelType = `getPanel -to $currentPanel`;
if ($panelType == "modelPanel")
{ modelEditor -e -xray ( !`modelEditor -q -xray $currentPanel` ) $currentPanel;
}