本文整理汇总了Python中maya.cmds.joint函数的典型用法代码示例。如果您正苦于以下问题:Python joint函数的具体用法?Python joint怎么用?Python joint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了joint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_wrist
def _create_wrist(self):
"""Creates the special wrist setup for the 3 different rotation axes of
Dave's wrist.
@todo: change the constraining to the PLY GRP to something save
"""
hand = '%s_hand_result_%s' % (self.side, self.nc.joint)
hand_end = '%s_handEnd_result_%s' % (self.side, self.nc.joint)
fore_arm = '%s_foreArm_result_%s' % (self.side, self.nc.joint)
# joints
cmds.select(cl=True)
root_jnt = cmds.joint(n='%s_wristRoot_%s' % (self.side, self.nc.joint))
end_jnt = cmds.joint(n='%s_wristEnd_%s' % (self.side, self.nc.joint))
tmp_end_jnt = cmds.joint(n='%s_wristTmpEnd_%s' % (self.side, self.nc.joint))
self.c.snap_a_to_b(root_jnt, hand)
self.c.snap_a_to_b(end_jnt, hand_end)
self.c.snap_a_to_b(tmp_end_jnt, hand_end)
# orient joints properly
self.orient_joint(root_jnt)
cmds.delete(tmp_end_jnt)
cmds.parent(end_jnt, w=True)
# constrain joints
cmds.parentConstraint(hand, root_jnt, mo=True)
cmds.pointConstraint(root_jnt, end_jnt, mo=True)
cmds.orientConstraint(root_jnt, end_jnt, mo=True)
# constrain hand const group
cmds.parentConstraint('%s_wristRotZ_PLY_%s' % (self.side, self.nc.group),
'%s_hand_const_%s' % (self.side, self.nc.group), mo=True)
cmds.parent(root_jnt, end_jnt, '%s_hand_%s' % (self.side, self.nc.group))
示例2: confirmJoints
def confirmJoints(self):
"""
draw joints in locator position
"""
#- Getting Ball and Toe Location
self.leftHipPos = cmds.xform('l_hip_Adjust_ctl', q = True, ws = True, t = True)
self.leftKneePos = cmds.xform('l_knee_Adjust_ctl', q = True, ws = True, t = True)
self.leftAnklePos = cmds.xform('l_ankle_Adjust_ctl', q = True, ws = True, t = True)
self.leftBallPos = cmds.xform('l_ball_Adjust_ctl', q = True, ws = True, t = True)
self.leftToePos = cmds.xform('l_toe_Adjust_ctl', q = True, ws = True, t = True)
self.leftHeelPos = cmds.xform('l_heel_PivotPosition', q = True, ws = True, t = True)
self.leftSideInPos = cmds.xform('l_sidein_PivotPosition', q = True, ws = True, t = True)
self.leftSideOutPos = cmds.xform('l_sideout_PivotPosition', q = True, ws = True, t = True)
#duplicate pivots
cmds.duplicate('l_heel_PivotPosition', n = 'r_heel_PivotPosition', rr = True)
cmds.xform('r_heel_PivotPosition', t = [-self.leftHeelPos[0], self.leftHeelPos[1], self.leftHeelPos[2]])
cmds.duplicate('l_sidein_PivotPosition', n = 'r_sidein_PivotPosition', rr = True)
cmds.xform('r_sidein_PivotPosition', t = [-self.leftSideInPos[0], self.leftSideInPos[1], self.leftSideInPos[2]])
cmds.duplicate('l_sideout_PivotPosition', n = 'r_sideout_PivotPosition', rr = True)
cmds.xform('r_sideout_PivotPosition', t = [-self.leftSideOutPos[0], self.leftSideOutPos[1], self.leftSideOutPos[2]])
cmds.select(cl = True)
print 'leg Parts : ' , self.legParts
for elem in self.legElement :
jointPos = cmds.xform(self.left + elem + '_Adjust_ctl', t = True, q = True, ws = True)
cmds.joint(n = '%s%s_jnt' %(self.left, elem), p = jointPos)
#- orient joint
cmds.joint(self.lHipJnt, e = True, oj = 'xzy', secondaryAxisOrient = 'yup', ch = True, zso = True)
#- delete position locators
cmds.delete(self.legParts)
示例3: build
def build(numBindJoints=6, numSpans=None, name='', numSkinJoints=3, width=None):
'''
builds a nurbs ribbon
If width is not specified, width will be set to numBindJoints
If numSpans is not specified, it will be set to numBindJoints
'''
if not width:
width = numBindJoints
if not numSpans:
numSpans = numBindJoints
main_grp = cmds.group(empty=1, name=(name + '_grp'))
plane = cmds.nurbsPlane(axis=(0, 1, 0), ch=0, lengthRatio=(1.0 / width), w=width, u=numSpans, name=(name + '_nurbsPlane'))[0]
cmds.parent(plane, main_grp)
# Creat Skin joints
skinJoints = []
skinJointPositions = common.pointsAlongVector( start=[width*.5, 0, 0], end=[width*-.5, 0, 0], divisions=(numSkinJoints-1) )
for index in range(len(skinJointPositions)):
cmds.select(main_grp)
j = cmds.joint(position = skinJointPositions[index], name=(name + '_' + str(index) + '_jnt'))
skinJoints.append(j)
# Add skinning to ribbon
cmds.skinCluster(skinJoints, plane, tsb=1, name=(plane + '_skinCluster'))
cmds.setAttr(plane+'.inheritsTransform', 0)
# Add follicles
for index in range(numBindJoints):
f = rivet.build( mesh=plane, paramU=(1.0 / (numBindJoints-1) * index), paramV=0.5, name=(name + '_' + str(index)))
cmds.parent(f, main_grp)
j = cmds.joint(name=(name + '_' + str(index) + '_bnd'))
示例4: createGuide
def createGuide(self, *args):
Base.StartClass.createGuide(self)
# Custom GUIDE:
cmds.addAttr(self.moduleGrp, longName="flip", attributeType='bool')
cmds.setAttr(self.moduleGrp+".flip", 0)
cmds.addAttr(self.moduleGrp, longName="indirectSkin", attributeType='bool')
cmds.setAttr(self.moduleGrp+".indirectSkin", 0)
cmds.setAttr(self.moduleGrp+".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string')
self.cvJointLoc, shapeSizeCH = ctrls.cvJointLoc(ctrlName=self.guideName+"_JointLoc1", r=0.3)
self.connectShapeSize(shapeSizeCH)
self.jGuide1 = cmds.joint(name=self.guideName+"_JGuide1", radius=0.001)
cmds.setAttr(self.jGuide1+".template", 1)
cmds.parent(self.jGuide1, self.moduleGrp, relative=True)
self.cvEndJoint, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName+"_JointEnd", r=0.1)
self.connectShapeSize(shapeSizeCH)
cmds.parent(self.cvEndJoint, self.cvJointLoc)
cmds.setAttr(self.cvEndJoint+".tz", 1.3)
self.jGuideEnd = cmds.joint(name=self.guideName+"_JGuideEnd", radius=0.001)
cmds.setAttr(self.jGuideEnd+".template", 1)
cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False))
ctrls.setLockHide([self.cvEndJoint], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz'])
cmds.parent(self.cvJointLoc, self.moduleGrp)
cmds.parent(self.jGuideEnd, self.jGuide1)
cmds.parentConstraint(self.cvJointLoc, self.jGuide1, maintainOffset=False, name=self.jGuide1+"_ParentConstraint")
cmds.parentConstraint(self.cvEndJoint, self.jGuideEnd, maintainOffset=False, name=self.jGuideEnd+"_ParentConstraint")
cmds.scaleConstraint(self.cvJointLoc, self.jGuide1, maintainOffset=False, name=self.jGuide1+"_ScaleConstraint")
cmds.scaleConstraint(self.cvEndJoint, self.jGuideEnd, maintainOffset=False, name=self.jGuideEnd+"_ScaleConstraint")
示例5: createJoints
def createJoints(prefix, lytObs, *args):
print "CreateJoints"
cmds.select(d=True)
ik_joints = []
for item in lytObs:
""" item[0] will be the joint
item[1] will be the position
item[2] will be the parent
"""
newJointName = item[0].replace("lyt_", prefix)
cmds.select(d=True)
if cmds.objExists(newJointName) == True:
cmds.delete(newJointName)
jnt = cmds.joint(p=item[1], n=newJointName )
ik_joints.append(jnt)
lytLen = len(lytObs)
for item in range(len(lytObs)):
if item != 0:
joint = lytObs[item][0].replace("lyt_", prefix)
jointParent = lytObs[item][2].replace("lyt_", prefix)
cmds.parent(joint, jointParent)
for jnt in ik_joints:
cmds.joint(jnt, e=True, oj='xyz', secondaryAxisOrient='yup', ch=True, zso=True)
return ik_joints
示例6: createFromPointList
def createFromPointList(ptList, orient=False, side='cn', part='chain', suffix='jnt'):
"""
Create joint chain from a list of point positions
@param ptList: List of points to create joint chain from
@type ptList: list
@param orient: Orient joints
@type orient: bool
@param side: Joint side name prefix
@type side: str
@param part: Joint part name
@type part: str
@param suffix: Joint name suffix
@type suffix: str
"""
# Clear selection
cmds.select(cl=True)
# Create joint chain
jntList = []
for i in range(len(ptList)):
jnt = cmds.joint(p=ptList[i], n=side + '_' + part + str(i + 1) + '_' + suffix)
if i and orient: cmds.joint(jntList[-1], e=True, zso=True, oj='xyz', sao='yup')
jntList.append(jnt)
# Return result
return jntList
示例7: template_joints
def template_joints(joints=None, reorient_children=True, reset_orientation=True):
if joints is None:
joints = cmds.ls(sl=True, type='joint')
if not joints:
raise RuntimeError('No joint selected to orient.')
if reorient_children:
children = cmds.listRelatives(fullPath=True, allDescendents=True, type='joint')
joints.extend(children)
red, green, blue = create_shaders()
orient_group = cmds.createNode('transform', name=ORIENT_GROUP)
manips = []
for joint in joints:
if reset_orientation:
cmds.makeIdentity(joint, apply=True)
cmds.joint(joint, edit=True, orientJoint='xyz', secondaryAxisOrient='yup', children=False, zeroScaleOrient=True)
if not cmds.listRelatives(joint, children=True):
zero_orient([joint])
continue
group, manip = create_orient_manipulator(joint, blue)
manips.append(manip)
cmds.parent(group, orient_group)
cmds.parentConstraint(joint, group)
cmds.setAttr(joint + '.template', 1)
cmds.select(manips)
示例8: reorientJoints
def reorientJoints(_joints, _up=False, _upVec=(0, 0, 1), _aimVec=(1, 0, 0)):
for topJoint in _joints:
# Clean translations
cmds.joint(topJoint, edit=True, oj="xyz", sao="zup", ch=True, zso=True)
if _up:
# Clean rotations
reorientRecursive(topJoint, _up, _upVec, _aimVec)
示例9: test_constrainLocators
def test_constrainLocators(self):
#--- Setup the scene
startJnt = cmds.joint(n='startJnt',p=(3, 0, 0))
endJnt = cmds.joint(n='endJnt',p=(3, 5, -2))
upObj = cmds.joint(n='upJnt',p=(4, 0, 0))
#--- Create the locators... tsk, tsk, external dependency, but why repo so much code here!?
result = self.rig._createLocators(name='test', start=startJnt, end=endJnt, startUpObj=upObj)
#--- Call method, get results
result = self.rig._constrainLocators(locators=result)
#--- Check Results
self.test.assertConstrained('test_btmLoc_pos','test_topLoc_aim',type='aim')
self.test.assertConstrained('test_topLoc_pos','test_btmLoc_aim',type='aim')
self.test.assertConstrained('test_topLoc_pos','test_midLoc_aim',type='aim')
self.test.assertConstrained('test_topLoc_pos','test_midLoc_pos',type='point')
self.test.assertConstrained('test_btmLoc_pos','test_midLoc_pos',type='point')
self.test.assertConstrained('test_topLoc_up','test_midLoc_up',type='point')
self.test.assertConstrained('test_btmLoc_up','test_midLoc_up',type='point')
btmPos = cmds.xform('test_btmLoc_up', q=1,ws=1, rp=1)
self.test.assertFloatListAlmostEqual(btmPos,[13,0,0])
# Twist the top
cmds.rotate(0,45,0,'test_topLoc_pos')
topPos = cmds.xform('test_topLoc_up', q=1,ws=1, rp=1)
midPos = cmds.xform('test_midLoc_up', q=1,ws=1, rp=1)
avgPos = [(topPos[0]+btmPos[0])/2.0, (topPos[1]+btmPos[1])/2.0, (topPos[2]+btmPos[2])/2.0]
self.test.assertListEqual(avgPos, midPos)
示例10: surfJnts
def surfJnts(name, pairL):
jntPairs = []
iks = []
j = 0
for pair in pairL:
jnts = []
i = 0
suff = ['_root', '_aim', '_up']
for point in pair:
cmds.select(point)
pos = cmds.xform(point, q=True, t=True, ws=True)
jnts.append(place.joint(0, name + str(j) + suff[i] + '_jnt', pad=2, rpQuery=False)[0])
i = i + 1
j = j + 1
# parent ik joints
cmds.parent(jnts[1], jnts[0])
# orient ik joints
cmds.joint(jnts[0], e=True, oj='zyx', secondaryAxisOrient='yup')
jnt.ZeroJointOrient(jnts[1])
# orient up vector jnt
cmds.parent(jnts[2], jnts[0])
jnt.ZeroJointOrient(jnts[2])
cmds.parent(jnts[2], w=True)
# append pairs to list
jntPairs.append(jnts)
# ik
ikhndl = cmds.ikHandle(sj=jnts[0], ee=jnts[1], sol='ikRPsolver', sticky='sticky')[0]
cmds.setAttr(ikhndl + '.visibility', False)
cmds.poleVectorConstraint(jnts[2], ikhndl)
iks.append(ikhndl)
# cleanup
place.cleanUp(jnts[0], SknJnts=True)
place.cleanUp(jnts[2], SknJnts=True)
place.cleanUp(ikhndl, World=True)
return jntPairs, iks
示例11: lock_joints
def lock_joints(self, moduleInfo):
## clear selection
cmds.select(clear=True )
joints = moduleInfo[0]
jointPositions = moduleInfo[1]
jointOrientations = moduleInfo[2]
jointRotationOrders = moduleInfo[3]
jointPreferredAngles = moduleInfo[4]
cmds.delete(self.containerName)
index = 0
## creating joints this way because when you select a joint and create joint, it corrects orientation
for joint in joints:
jointName = joint
jointPos = jointPositions[index]
parentJoint = ''
childJoint = ''
if index > 0:
parentJoint = self.moduleName + ":" + self.jointInfo[index-1][0]
cmds.select(parentJoint, replace = True)
newJoint = cmds.joint(name = self.moduleName + ":" + self.jointInfo[index][0], position = jointPositions[index])
if index > 0:
cmds.joint(parentJoint, edit = True, orientJoint = "xyz", secondaryAxisOrient = "yup")
cmds.joint(newJoint, edit = True, orientation = jointOrientations[index])
index += 1
示例12: MakeJntAndIKs
def MakeJntAndIKs(side):
"""
选择两圈眼球上的线,生成骨骼和ik,side的值例如:R_In or R_Out
ps: 选择骨骼链的子物体,打组,centerPivot,在原点生成一个骨点,用组约束骨点,正确命名,然后将IK组分别放到对应骨点下边。
"""
lx_start=mc.xform('loc_eyeCenter01',q=1,ws=1,t=1)
lx_mouthPnt= mc.filterExpand(sm=31)
mc.select (cl=1)
lx_Jnts=[]
lx_IKs = []
for i in lx_mouthPnt :
lx_end=mc.xform(i,q=1,ws=1,t=1)
lx_stJnt=mc.joint (n=("Jnt_"+side+"_st"),p=(lx_start[0],lx_start[1],lx_start[2]),radius=0.1)
lx_edJnt=mc.joint (n=("Jnt_"+side+"_ed"),p=(lx_end[0],lx_end[1],lx_end[2]),radius=0.1)
lx_scik =mc.ikHandle (n=("scik_"+side+str(01)),sj=lx_stJnt,ee=lx_edJnt,sol="ikSCsolver")
#mc.setAttr((str(lx_scik[0]) +".visibility") ,0)
mc.select(cl=1)
lx_Jnts.append(lx_stJnt)
lx_IKs .append(lx_scik[0])
mc.select(lx_Jnts,r=1)
mc.group(n=("grp_Jnts"+side))
mc.select(lx_IKs,r=1)
mc.group(n=("grp_iks"+side))
mc.setAttr((str("grp_iks"+side) +".visibility") ,0)
#3.选择眼皮曲线,执行脚本,生成
def MakeEyeLidJnts(cuvs):
示例13: _iterate_
def _iterate_(self):
self.call2_func = self.test2_func
_first = mc.joint(n = "first")
#_first = mc.createNode('transform',n = "first")
for i in range(self.int_targetCount):
self.progressBar_set(status = ("Pass 1: Substantiating Call %i"%i), progress = i, maxValue = self.int_targetCount)
mc.select(cl=True)
string = mc.joint(n = "baseobj_{0}".format(i))
if i:
for ii in (range(i)):
string = mc.joint(n = "obj_{0}".format(i))
#mc.parent(string,world = True)
#string = mc.createNode('network',n = "obj_{0}".format(i))
#string = mc.createNode('transform',n = "obj_{0}".format(i))
#string = mc.createNode('transform',n = "sameName".format(i))
#_group = mc.group(n = "obj_{0}".format(i), em=True)
#string = mc.parent(string,_group)[0]
t1 = time.clock()
self.test1_func(_first)
t2 = time.clock()
self.l_times_1.append(t2-t1)
t1 = time.clock()
#self.l_roots_2.extend( [self.test2_func(self._toCall)] )
self.call2_func(string)
t2 = time.clock()
self.l_times_2.append(t2-t1)
示例14: create_joints
def create_joints():
'''Subelements: vertecies, faces, edges should be selected'''
# Get selected object name
selection_list = cmds.ls(selection=True)
for selection in selection_list:
selected_object = selection.split('.')[0]
break
old_loc_list = cmds.ls('*LOC*', flatten=True)
#Create locators constrained to subelements
HZrivet.UI.HZrivet_finalCC()
current_loc_list = cmds.ls('*LOC*', flatten=True)
#Filter created locators
new_loc_list = [loc for loc in current_loc_list if loc not in old_loc_list]
# Get list of locators names and apply it as a prefix to a joint name
loc_list = [loc for loc in new_loc_list if 'Shape' not in loc]
root_joint = 'root'
if not cmds.objExists(root_joint):
cmds.select(clear=True)
cmds.joint(name=root_joint)
root_p_constraint = cmds.pointConstraint(selected_object, root_joint)
root_o_constraint = cmds.orientConstraint(selected_object, root_joint)
cmds.delete(root_p_constraint, root_o_constraint)
for loc in loc_list:
joint_prefix = re.sub("\D", "", loc)
joint_name = 'JNT_' + joint_prefix
cmds.select(clear=True)
cmds.joint(name=joint_name)
cmds.pointConstraint(loc, joint_name)
cmds.orientConstraint(loc, joint_name)
cmds.parent(joint_name, 'root')
示例15: j_BodyFix
def j_BodyFix():
# Get The Goal Joint position
position = dict()
dupJnt = ['ShoulderPart2_L','Elbow_L','ElbowPart1_L','HipPart2_L','Knee_L','KneePart1_L']
for jnt in dupJnt:
position[jnt] =mc.xform(jnt,ws=1,t=1,q=1)
# Create Joint And Ikhandle From position
newJnt = []
na =1;
for j in dupJnt:
if mc.objExists(('Fix'+j)):
mc.select(('Fix'+j),r=1)
break;
newJnt.append(mc.joint(n=('Fix'+j),p=position[j],radius=1.75))
if na%3==0:
# Create IKHandle With ikRPsolver , Then Mirror With IkHandle
mc.joint(newJnt[0],e=1,zso=1,oj='xyz',sao='yup')
mc.joint(newJnt[1],e=1,zso=1,oj='xyz',sao='yup')
mc.setAttr('%s.jointOrient'%newJnt[2],0,0,0)
ikhand = mc.ikHandle(name=('rpik_'+newJnt[1]+'01'),sj=newJnt[0],ee=newJnt[2],sol = 'ikSCsolver')
mc.setAttr('%s.v'%ikhand[0],0)
# mirrorJoint -mirrorYZ -mirrorBehavior -searchReplace "_L" "_R";
mc.mirrorJoint(newJnt[0],mirrorYZ =1,mirrorBehavior =1,searchReplace=('_L','_R'))
mc.parent(ikhand[0],j)
mc.parent((re.sub('_L',"_R",ikhand[0])),(re.sub('_L','_R',j)))
mc.parent(newJnt[0],dupJnt[na-3])
mc.parent((re.sub("_L","_R",newJnt[0])),(re.sub('_L','_R',dupJnt[na-3])))
newJnt = []
mc.select(clear=1)
na=na+1;