本文整理汇总了Python中maya.cmds.ikHandle函数的典型用法代码示例。如果您正苦于以下问题:Python ikHandle函数的具体用法?Python ikHandle怎么用?Python ikHandle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ikHandle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: switchToIK
def switchToIK( control, ikHandle=None, poleControl=None, onCmd=None, offCmd=None ):
'''
this proc will align the IK controller to its fk chain
flags used:
-control this is the actual control being used to move the ikHandle - it is assumed to be the same object as the ikHandle, but if its different (ie if the ikHandle is constrained to a controller) use this flag
-pole tells the script the name of the pole controller - if there is no pole vector control, leave this flag out
-ikHandle this flag specifies the name of the ikHandle to work on
-onCmd this flag tells the script what command to run to turn the ik handle on - it is often left blank because its assumed we're already in ik mode
-offCmd this flag holds the command to turn the ik handle off, and switch to fk mode
NOTE: if the offCmd isn't specified, it defaults to: if( `getAttr -se ^.ikb` ) setAttr ^.ikb 1;
symbols to use in cmd strings:
^ refers to the ikHandle
# refers to the control object
example:
zooAlignIK "-control somObj -ikHandle ikHandle1 -offCmd setAttr #.fkMode 0";
'''
if ikHandle is None:
ikHandle = control
if callable( onCmd ):
onCmd( control, ikHandle, poleControl )
joints = cmd.ikHandle( ikHandle, q=True, jl=True )
effector = cmd.ikHandle( ikHandle, q=True, ee=True )
effectorCtrl = listConnections( '%s.tx' % effector, d=False )[ 0 ]
mel.zooAlign( "-src %s -tgt %s" % (effectorCtrl, control) )
if poleControl is not None and objExists( poleControl ):
pos = mel.zooFindPolePosition( "-start %s -mid %s -end %s" % (joints[ 0 ], joints[ 1 ], effectorCtrl) )
move( pos[0], pos[1], pos[2], poleControl, a=True, ws=True, rpr=True )
if callable( offCmd ):
offCmd( control, ikHandle, poleControl )
示例2: uiCmd_createSplineJointEachSpans
def uiCmd_createSplineJointEachSpans( *args ):
selections = cmds.ls( sl=1 )
curve = selections[0]
curveShape = cmds.listRelatives( curve, s=1 )[0]
minValue = cmds.getAttr( curveShape+'.minValue' )
maxValue = cmds.getAttr( curveShape+'.maxValue' )
spans = cmds.getAttr( curveShape+'.spans' )
paramRange = maxValue - minValue
eachParamRate = paramRange / spans
infos = []
for i in range( 0, spans+1 ):
info = cmds.createNode( 'pointOnCurveInfo' )
cmds.connectAttr( curveShape+'.local', info+'.inputCurve' )
cmds.setAttr( info+'.parameter', eachParamRate*i )
infos.append( info )
cmds.select( d=1 )
jnts = [ cmds.joint() ]
for i in range( spans ):
cmds.select( jnts[-1] )
jnt = cmds.joint()
jnts.append( jnt )
distNode = cmds.createNode( 'distanceBetween' )
cmds.connectAttr( infos[i]+'.position', distNode+'.point1' )
cmds.connectAttr( infos[i+1]+'.position', distNode+'.point2' )
cmds.connectAttr( distNode+'.distance', jnt+'.tx' )
cmds.ikHandle( sj=jnts[0], ee=jnts[-1], sol='ikSplineSolver', ccv=False, pcv=False, curve=curveShape )
示例3: __init__
def __init__(self, curve_sel, vertex_list):
self.curve_sel = curve_sel
self.verts = vertex_list
self.find_length = Find_Out()
self.link_length = self.find_length.edge_length(self.verts)
self.chain_length = self.find_length.curve_length(self.curve_sel)
self.link_total = int(self.chain_length/self.link_length)
cmds.duplicate(self.curve_sel, n = 'buildCurve')
cmds.rebuildCurve('buildCurve', ch = 1, rpo = 1, rt = 0, end = 1, kr = 2, kep = 1, kt = 0, kcp = 0, s = self.link_total/2, d = 3, tol = 0.01 )
self.num_cv = int(cmds.getAttr ('buildCurve.degree'))+ (cmds.getAttr ('buildCurve.spans'))
for dummy_cv in range(self.num_cv):
dummy_cv_pos = (cmds.getAttr ('buildCurve.cv['+ str(dummy_cv) +']'))
if dummy_cv == 0:
cmds.joint(n=self.curve_sel+'_jointRoot',p = dummy_cv_pos[0])
elif dummy_cv == self.num_cv - 1:
cmds.joint(n=self.curve_sel+'_jointEnd', p = dummy_cv_pos[0])
else:
cmds.joint(n=self.curve_sel+'_joint_'+(str(dummy_cv)),p = dummy_cv_pos[0])
cmds.delete('buildCurve')
cmds.ikHandle( sj = (self.curve_sel+'_jointRoot'), ee = (self.curve_sel+'_jointEnd'), c = self.curve_sel,
sol = 'ikSplineSolver', scv = 0, pcv = 0, ccv = 0, ns = 4)
示例4: ik_stretch
def ik_stretch(ikhnd):
'''
'''
jts = cmds.ikHandle(ikhnd, q=True, jl=True)
cu_s = cmds.ikHandle(ikhnd, q=True, c=True)
cu = cmds.listRelatives(cu_s, p=1)[0]
cmds.addAttr(ikhnd, longName='ik_stretch', k=1, defaultValue=1.0, minValue=0.0, maxValue=1.)
dcu = cmds.duplicate(cu, n=cu + '_base_scale')[0]
dcu_s = cmds.listRelatives(dcu, c=1)[0]
cf = cmds.createNode('curveInfo')
dcf = cmds.createNode('curveInfo')
bl = cmds.createNode('blendTwoAttr')
md = cmds.createNode('multiplyDivide')
cmds.connectAttr(cu_s + '.worldSpace', cf + '.inputCurve')
cmds.connectAttr(dcu_s + '.worldSpace', dcf + '.inputCurve')
cmds.connectAttr(dcf + '.arcLength', bl + '.input[0]')
cmds.connectAttr(cf + '.arcLength', bl + '.input[1]')
cmds.connectAttr(ikhnd + '.ik_stretch', bl + '.attributesBlender')
cmds.connectAttr(bl + '.output', md + '.input1X')
cmds.setAttr(md + '.input2X', cmds.getAttr(cf + '.arcLength'), l=1)
cmds.setAttr(md + '.operation', 2)
cmds.setAttr(dcu + '.v', 0)
for j in jts:
cmds.connectAttr(md + '.outputX', j + '.sx')
return dcu
示例5: RMIdentifyIKJoints
def RMIdentifyIKJoints(self,ikHandle):
endEffector = cmds.ikHandle(ikHandle, q = True, endEffector = True)
EndJoint = RMRigTools.RMCustomPickWalk (endEffector, 'joint', 1, Direction = "up")
EndJoint = RMRigTools.RMCustomPickWalk (EndJoint[len(EndJoint)-1], 'joint', 1)
EndJoint = EndJoint[1]
StartJoint = cmds.ikHandle(ikHandle, q = True, startJoint = True)
return RMRigTools.FindInHieararchy (StartJoint, EndJoint)
示例6: _create_reverse_setup
def _create_reverse_setup(self):
# Create Ik handles
ball_ik, ball_effector = cmds.ikHandle(sj=self.joint_detail['ankle'], ee=self.joint_detail['ball'], sol="ikSCsolver")
tip_ik, tip_effector = cmds.ikHandle(sj=self.joint_detail['ball'], ee=self.joint_detail['tip'], sol="ikSCsolver")
self.ik_detail['ball'] = ball_ik
self.ik_detail['tip'] = tip_ik
示例7: build
def build(startJoint,endJoint,solver='ikSCsolver',curve='',ikSplineOffset=0.0,prefix=''):
'''
INPUTS:
@input startJoint: Start joint for the IK handle
@inputType startJoint: str
@input endJoint: End joint for the IK handle
@inputType endJoint: str
@input solver: IK Solver to use
@inputType solver: str
@input curve: Input curve for splineIK
@inputType curve: str
@input ikSplineOffset: Offset value for ikSplineSolver
@inputType ikSplineOffset: float
@input prefix: Name prefix for all builder created nodes
@inputType prefix: str
'''
# Check joints
if not mc.objExists(startJoint): raise Exception('Joint '+startJoint+' does not exist!!')
if not mc.objExists(endJoint): raise Exception('Joint '+endJoint+' does not exist!!')
# Check solver type
ikType = ['ikSplineSolver','ikSCsolver','ikRPsolver','ik2Bsolver']
if not ikType.count(solver):
raise Exception('Invalid ikSlover type specified ("'+solver+ '")!!')
# Check curve
createCurve = False
if solver == ikType[0]: # solver = ikSplineSolver
if not mc.objExists(curve):
createCurve = True
# Extract name prefix from joint name
if not prefix: prefix = glTools.utils.stringUtils.stripSuffix(startJoint)
mc.select(cl=True)
#-----------------
# Create ikHandle
ik = []
if solver == ikType[0]:
# Spline IK solver
ik = mc.ikHandle(sj=startJoint,ee=endJoint,sol=solver,curve=curve,ccv=createCurve,pcv=False)
else:
# Chain IK solver
ik = mc.ikHandle(sj=startJoint,ee=endJoint,sol=solver)
# Clear selection (to avoid printed warning message)
mc.select(cl=True)
# Rename ikHandle and endEffector
ikHandle = str(mc.rename(ik[0],prefix+'_ikHandle'))
ikEffector = str(mc.rename(ik[1],prefix+'_ikEffector'))
# Set ikHandle offset value
mc.setAttr(ikHandle+'.offset',ikSplineOffset)
# Return result
return ikHandle
示例8: createListRig
def createListRig(self, list,nameElement,ikHandleBase=None):
for index in range(len(list)):
tuplePoint = list[index]
cmds.joint(p=tuplePoint,name=nameElement + str(index))
cmds.ikHandle( sj=ikHandleBase ,ee=nameElement + "0")
cmds.select(nameElement + str(index))
for index in range(len(list)-1) :
cmds.select(nameElement + str(index+1))
cmds.ikHandle(sj=nameElement + str(index))
示例9: ikSplineSolver
def ikSplineSolver(self,
startJoint = None,
endEffector = None,
curve = None,
side = None,
name = None,
suffix = None,
parent = None,
hide = False):
#--- do the proper naming checks
self.__check_ik_name(startJoint = startJoint, endEffector = endEffector,
side = side, name = name, suffix = suffix)
#--- create the ik_handle
if curve == None:
ik = cmds.ikHandle(startJoint = startJoint,
endEffector = endEffector,
createCurve = True,
name = self.ik_name, solver = 'ikSplineSolver')
else:
if cmds.objExists(curve):
ik = cmds.ikHandle(startJoint = startJoint,
endEffector = endEffector,
curve = curve, createCurve = False,
name = self.ik_name, solver = 'ikSplineSolver')
else:
raise Exception('There is no specified curve: ' + curve )
#--- rename the effector
eff = cmds.rename(ik[1], ik[0] + 'EFF')
#--- store the ik_handle and effector in a list to return
ik_handle = []
if curve == None:
#--- rename the automated curve
crv = cmds.rename(ik[-1], ik[0] + 'CRV')
ik_handle = [ik[0], eff, crv]
else:
ik_handle = [ik[0], eff, curve]
#--- parent the ik_handle under the specified parent
if parent:
cmds.parent(ik_handle[0], parent)
#--- hide the ikHandle
if hide:
cmds.setAttr(ik_handle[0] + '.v', 0)
cmds.select(clear = 1)
return ik_handle
#end def ikSplineSolver()
#end class IkHandle()
示例10: make_joint
def make_joint():
"""
Create a few joints
"""
cmds.select(d=True)
cmds.joint(p=(0, 0, 0), name="joint1")
cmds.joint(p=(0, 4, 0), name="joint2")
cmds.joint("joint1", e=True, zso=True, oj="xyz")
cmds.joint(p=(0, 8, -1), name="joint3")
cmds.joint("joint2", e=True, zso=True, oj="xyz")
cmds.joint(p=(2, 9, 3), name="joint4")
cmds.joint("joint3", e=True, zso=True, oj="xyz")
cmds.ikHandle(n="tendon", sj="joint1", ee="joint4", p=2, w=0.5)
示例11: create_ik_setup
def create_ik_setup(self):
"""@todo: insert doc for create_ik_setup"""
# ik arm, hand
ik_arm = cmds.ikHandle(sj=self.ik_jnts[0], ee=self.ik_jnts[2], sol='ikRPsolver')
cmds.rename(ik_arm[1], '%s_%s_%s' % (self.side, 'arm', self.nc.effector))
ik_arm = cmds.rename(ik_arm[0], '%s_%s_%s' % (self.side, 'arm', self.nc.ikhandle))
ik_hand = cmds.ikHandle(sj=self.ik_jnts[2], ee=self.ik_jnts[3])
cmds.rename(ik_hand[1], '%s_%s_%s' % (self.side, 'arm', self.nc.effector))
ik_hand = cmds.rename(ik_hand[0], '%s_%s_%s' % (self.side, 'hand', self.nc.ikhandle))
cmds.parent(ik_arm, ik_hand, self.controls['handik'])
self.create_ik_arm_stretch()
pv = cmds.poleVectorConstraint(self.controls['elbow'], ik_arm, weight=1)
self.create_elbow_pin()
# twist switch
cmds.connectAttr('%s.twist' % self.controls['hand'], '%s_%s_%s.dTwistControlEnable' % (self.side, 'upperArm', self.nc.ikhandle), f=True)
cmds.connectAttr('%s.twist' % self.controls['hand'], '%s_%s_%s.dTwistControlEnable' % (self.side, 'foreArm', self.nc.ikhandle), f=True)
示例12: createToeIk
def createToeIk(self, ball, toe, iksSolver, footCtrl, *args):
""" Create an Ik Solver """
solverName = toe.replace("ikPJnt_", "toeSolver_")
iktSolver = cmds.ikHandle(n=solverName, sj=ball, ee=toe, sol="ikRPsolver")
""" Create attributes on the foot control """
attributes = ("toe_roll", "toe_twist", "toe_bank")
cmds.select(footCtrl)
for attr in attributes:
cmds.addAttr(shortName=attr, longName=attr, defaultValue=0, k=True)
cmds.select(d=True)
""" Create a group at the toe """
groupName = toe.replace("ikPJnt_", "grp_ik_")
grpPos = cmds.xform(toe, q=True, t=True, ws=True)
toeGrp = cmds.group(name=groupName, em=True, p=footCtrl[0])
cmds.select(toeGrp)
cmds.xform(toeGrp, t=grpPos, ws=True)
cmds.select(d=True)
#cmds.parent(toeGrp, footCtrl)
#cmds.parent(iktSolver, footCtrl)
#cmds.parent(iksSolver, toeGrp)
#cmds.parent(iktSolver, toeGrp)
cmds.connectAttr(footCtrl[0]+".toe_roll", toeGrp+".rotateX")
cmds.connectAttr(footCtrl[0]+".toe_twist", toeGrp+".rotateY")
cmds.connectAttr(footCtrl[0]+".toe_bank", toeGrp+".rotateZ")
示例13: setup
def setup(self):
#duplicate given joints
cmds.duplicate( self.oldJoint1, n=self.dupJoint1, po=True )
cmds.duplicate( self.oldJoint2, n=self.dupJoint2, po=True )
cmds.parent( self.dupJoint2, self.dupJoint1 )
cmds.parent(self.dupJoint1, w=True)
#create rp ik
ik = cmds.ikHandle(
sol='ikRPsolver',
sj=self.dupJoint1,
ee=self.dupJoint2,
n=self.ik
)[0]
#zero pole vectors
cmds.setAttr("{0}.poleVectorX".format(self.ik), 0)
cmds.setAttr("{0}.poleVectorY".format(self.ik), 0)
cmds.setAttr("{0}.poleVectorZ".format(self.ik), 0)
#parent to bindJoint
cmds.select( self.oldJoint1)
clav = cmds.pickWalk(d='Up')
cmds.parent( self.ik, self.oldJoint1)
cmds.parent( self.dupJoint1, clav )
#hide ik
cmds.setAttr( '{0}.v'.format(ik), 0 )
# hide them they ugly
cmds.setAttr( "{0}.v".format(self.dupJoint1), 0)
cmds.setAttr( "{0}.v".format(self.dupJoint2), 0)
示例14: _setup
def _setup(self):
sj = self.joints[0]
ej = self.joints[-1]
self.spineCurve = 'curve_bindSpine'
# setup IK
ikSpine = cmd.ikHandle(sj=sj, ee=ej, name='ikHandle_bindSpine', sol='ikSplineSolver', createCurve=True,
ns=2)
cmd.rename(ikSpine[2], self.spineCurve)
# clusters
clusterReturn = general.clusterCurve(self.spineCurve, 'cluster_spineIK')
clusters = clusterReturn[0]
clusterGrp = clusterReturn[1]
# ==================controllers setup=============================
if self.upperCtrl == None:
self.upperCtrl = self._drawCtrl('ctrl_upperTorso', self.joints[-2])
if self.lowerCtrl == None:
self.lowerCtrl = self._drawCtrl('ctrl_lowerTorso', self.joints[1])
for i in [0, 1]:
cmd.parentConstraint(self.lowerCtrl, clusters[i], mo=True)
for i in [2, 3, 4]:
cmd.parentConstraint(self.upperCtrl, clusters[i], mo=True)
示例15: create_ik_setup
def create_ik_setup(self):
"""Creates the IK setup."""
ik = cmds.ikHandle(sj=self.result_jnts[0], ee=self.result_jnts[1])
cmds.rename(ik[1], '%s_%s_%s' % (self.side, 'shoulder', self.nc.effector))
ik = cmds.rename(ik[0], '%s_%s_%s' % (self.side, 'shoulder', self.nc.ikhandle))
cmds.parent(ik, self.controls['ik'])
self.create_ik_stretch()