Skip to content

Instantly share code, notes, and snippets.

@manhha00
manhha00 / piston move
Created December 8, 2017 07:45
maya -mel -expression - piston move
float $sp = pSphere1.translateZ; //controller
pCylinder1.rotateY = -(9 * (frame*$sp)) ; // rotateObject
pCylinder2.translateZ = 9 + (sin(((frame*$sp)*3.14/2)/10))*1.5; //translateObject
@manhha00
manhha00 / createCircleInCenter()
Created December 7, 2017 19:23
maya - mel - createCircleInCenter
global proc createCircleInCenter() {
string $sel[] = (`ls - sl`);
int $num = size($sel);
for ($i = 0 ; $i < $num ; $i++) {
float $pos[] = (`xform -ws -q -sp $sel[$i]`);
float $rotation[] = (`xform -ws -q -ro $sel[$i]`);
string $controller[] = (`circle -c $pos[0] $pos[1] $pos[2] -nr 1 0 0 -r 0.8 -d 3 `);
xform -cp $controller[0];
xform -ro $rotation[0] $rotation[1] $rotation[2] $controller[0];
parentConstraint $controller $sel[$i] ;
@manhha00
manhha00 / shelfTabLayout
Created December 3, 2017 19:30
maya - mel - create shelf tab
window
-title "havm";
shelfTabLayout
-image "smallTrash.png"
-imageVisible true mainShelfTab;
shelfLayout "havm";
setParent ..;
showWindow;
@manhha00
manhha00 / ae - expression - myLayer command
Created December 2, 2017 03:33
ae - expression - myLayer command
timeToFrames(time - myLayer.startTime);
or
timeToFrames(time - myLayer.inPoint);
@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;
}
@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 - 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 / 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 / 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 / remove pre name in mel
Created November 16, 2017 12:02
remove pre name in mel
namespace -mv "insert_namespace_here" ":" -force;