Posts

Showing posts from August, 2017

animCurve, key values and time

import maya.cmds as mc; ## Querying # Current time crntT = mc.currentTime(q=1); # Getting anim nodes of current key selection animNodesOfSelectedKeys = mc.keyframe(q=1,sl=1,n=1); offsetval= 12.34; if animNodesOfSelectedKeys:      for aNode in animNodesOfSelectedKeys:           # Current time value of selected key curve           keyCurveValue = mc.keyframe(aNode,q=1,ev=1,t=(crntT,crntT))[0];           # Num of keys of an animCurve node           numKeys = mc.keyframe(animCurveNode,q=1,keyframeCount=1);           # All key "TIMES"           times = mc.keyframe(animCurveNode,index=(0,numKeys-1),q=1);           # All key time "VALUES"           vals = mc.keyframe(animCurveNode,t=(times[0],times[len(times)-1]),q=1,valueChange=1);  ...

World position of vtx using MVector

import maya.cmds as mc; from maya.OpenMaya import MVector; verts = mc.filterExpand( poly + ".vtx[*]", sm=31 ); for vtx in verts: pvec = MVector( *mc.pointPosition( vtx ) );

aimConstraint command

def _sample_aimConstraint(): import random; import maya.cmds as mc; sL1 = mc.spaceLocator()[0]; sL2 = mc.spaceLocator()[0]; sL3 = mc.spaceLocator()[0]; mc.xform(sL2,ws=1,t=(random.random()*10,random.random()*10,random.random()*10)); mc.xform(sL3,ws=1,t=(random.random()*10,random.random()*10,random.random()*10)); mc.aimConstraint(sL2,sL1,aim=[1,0,0],u=[0,1,0],wut="object",wuo=sL3);