Skip to content

Instantly share code, notes, and snippets.

@manhha00
manhha00 / maya - python - get all key bind with mesh
Created January 11, 2018 16:00
maya - python - get all key bind with mesh
import maya.cmds as cmds
sel = cmds.ls(sl = True)
jnts = cmds.skinCluster(sel, inf = True, q = True)
cmds.select(jnts)
@manhha00
manhha00 / maya - mel - create loc in pos
Created January 10, 2018 14:29
maya - mel - create loc in pos
string $currentTool = `currentCtx`;
setToolTo moveSuperContext;
vector $pos = `manipMoveContext -q -p Move`;
string $loc[] = `spaceLocator -n "average#"`;
move -ws -a ($pos.x) ($pos.y) ($pos.z) $loc;
setToolTo $currentTool;
@manhha00
manhha00 / move - rotate - xform
Created January 8, 2018 17:34
maya - python - move - rotate - xform
import maya.cmds as cmds
pos = cmds.xform('chest_JNT_JNT', q=1 , ws =1 , t=1)
print pos
cmds.xform('chest2', ws =1, t =pos)
cmds.move( pos[0] , pos[1] , pos[2] , 'chest2', rpr=1)
rot = cmds.xform('chest_JNT_JNT', q=1 , ws =1 , ro=1)
cmds.xform('chest2', ws=1, ro= (rot[0] , rot[1] , rot[2]))
cmds.rotate(0, -180, 0 ,'chest2', os = 1, r=1 )
@manhha00
manhha00 / maya - mel - key object attr
Created December 29, 2017 15:43
maya - mel - key object attr
string $sel[] = `ls -sl`;
string $attrList[];
for ($current in $sel)
{
$attrList = `listAttr -k $current`;
for ($attr in $attrList)
{
int $keyCount = `keyframe -at $attr-query -kc $current`;
if ($keyCount > 0)
setKeyframe -at $attr $current;
@manhha00
manhha00 / select all joint in bind
Created December 25, 2017 03:36
maya - python - select all joint in bind of selected mesh
import maya.cmds as cmds
sel = cmds.ls(sl = True)
jnts = cmds.skinCluster(sel, inf = True, q = True)
cmds.select(jnts)
@manhha00
manhha00 / vertextToObjectSelect
Created December 9, 2017 15:46
maya - mel - select object from vertext selected - Buexe - cgsociety
$sel = `ls -sl`;
select -clear;
SelectToggleMode;
for ( $s in $sel ) {
string $buff[];
tokenize $s "." $buff;
if ( size ( $buff ) == 2 )
select -r $buff[0];
}
@manhha00
manhha00 / proc string argument
Created December 9, 2017 15:02
maya - mel - proc string argument
string $stringB = "Maya";
window;
columnLayout;
button -l "test" -command ("Test(\"string \",\""+$stringB+"\")") - w 150;
showWindow;
global proc Test(string $stringTestA, string $stringTestB)
{
print ($stringTestA + $stringTestB);
}
@manhha00
manhha00 / listConnections - nodeType
Created December 9, 2017 15:01
maya - mel - listConnections nodeType by RobTheBloke
// this function takes the name of a node and prints
// the names of all animated attributes
proc listAttachedAnimCurves(string $node) {
// get the connections and connected nodes
$src_a = `listConnections -s true -d false -c true $node`;
$src_n = `listConnections -s true -d false $node`;
print($node+"\n");
@manhha00
manhha00 / moveZero
Created December 9, 2017 11:14
maya - mel - select edges and move vertex Z to 0
global proc havm_moveZero() {
string $sel[]= (`ls -sl`);
//print ($sel[1] + "\n");
string $veSel[] = (`polyListComponentConversion -fe -tv $sel`);
string $vertex[] = (`filterExpand -ex 1 -sm 31 ($veSel) `);
int $n = size($vertex);
print $n;
print "\n";
@manhha00
manhha00 / maya - mel - angle2Edges
Created December 9, 2017 10:01
angle between 2 edges
float $o[]= (`pointPosition -w polySurface70.vtx[120]`);
vector $O= << $o[0] , $o[1] , $o[2] >>; // start
float $u[]= (`pointPosition -w polySurface70.vtx[122]`);
vector $U= << $u[0] , $u[1] , $u[2] >>; // end0
$U = $U - $O;
float $v[]= (`pointPosition -w locator1`);
vector $V= << $v[0] , $v[1] , $v[2] >>; // end1
$V = $V - $O;