本文整理汇总了Python中maya.cmds.parentConstraint函数的典型用法代码示例。如果您正苦于以下问题:Python parentConstraint函数的具体用法?Python parentConstraint怎么用?Python parentConstraint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parentConstraint函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: addNoiseOnControl
def addNoiseOnControl(Object, Control):
if Object.__class__ == list:
pass
elif Object.__class__ in [str, unicode]:
Object = [Object]
else:
"Not Valid Arguments on Add Noise"
return None
Expresion = """//{0}
{0}.rotateX=`noise((time+{2})*{1}.frequency)`*{1}.amplitud;
{0}.rotateY=`noise((time+{2}+30)*{1}.frequency)`*{1}.amplitud;
{0}.rotateZ=`noise((time+{2}+60)*{1}.frequency)`*{1}.amplitud;
{0}.ty=`noise((time+{2}+90)*{1}.frequency)`*{1}.movY + {1}.movY;
"""
if not isNoiseControl(Control):
addAttributes(Control)
for eachObject in Object:
constraints = constraintComponents(gessFrom=eachObject)
ResetGroup = RMRigTools.RMCreateGroupOnObj(eachObject, Type="child")
for eachkey in constraints.constraintDic:
cmds.delete(eachkey)
cmds.parentConstraint(ResetGroup, constraints.constraintDic[eachkey]["affected"], mo=True)
ExpressionNode = cmds.expression(
name="NoiseMainExpresion", string=Expresion.format(ResetGroup, Control, random.uniform(0, 100))
)
开发者ID:rendermotion,项目名称:RMMel,代码行数:29,代码来源:NoisePatternRig.py
示例2: create_spine_rig
def create_spine_rig(base_curve, rig_region_name, pelvis, cog, spine_1, spine_2, spine_3, spine_4, neck):
# create group to contain all rigging nodes
cmds.select(cl=True)
spine_group = cmds.group(em=True, n=rig_region_name + '_group')
cmds.select(spine_group, base_curve, r=True)
cmds.parent()
# add the arm group node to the base curve rig nodes attr
add_node_to_rig_nodes(base_curve, rig_region_name, spine_group)
cog_curve, cog_curve_group = jt_ctl_curve.create(cog, 'star_5', lock_unused=False)
cmds.setAttr(cog_curve + '.scale', 3,3,3)
cmds.select(cog_curve, r=True)
cmds.makeIdentity(apply=True, t=0, r=0, s=1, n=0)
cmds.select(cog_curve, cog, r=True)
cmds.parentConstraint(mo=True, weight=1)
cmds.scaleConstraint(mo=True, weight=1)
cmds.select(cog_curve_group, base_curve, r=True)
cmds.parent()
pelvis_curve, pelvis_curve_group = jt_ctl_curve.create(pelvis, 'waist', True, True, True, True)
spine_1_curve, spine_1_curve_group = jt_ctl_curve.create(spine_1, 'circle', True, True, True, True)
spine_2_curve, spine_2_curve_group = jt_ctl_curve.create(spine_2, 'circle', True, True, True, True)
spine_3_curve, spine_3_curve_group = jt_ctl_curve.create(spine_3, 'circle', True, True, True, True)
spine_4_curve, spine_4_curve_group = jt_ctl_curve.create(spine_4, 'circle', True, True, True, True)
neck_curve, neck_curve_group = jt_ctl_curve.create(neck, 'circle', True, True, True, True)
# parent fk controlls to spine group
cmds.select(cog_curve_group, pelvis_curve_group, spine_1_curve_group, spine_2_curve_group, spine_3_curve_group, spine_4_curve_group, neck_curve_group, spine_group, r=True)
cmds.parent()
开发者ID:MaxIsJames,项目名称:jt_tools,代码行数:33,代码来源:jt_autorig.py
示例3: keyToOn
def keyToOn():
controller = mc.ls(sl=True)[0]
channelBox = mel.eval('global string $gChannelBoxName; $temp=$gChannelBoxName;') #fetch maya's main channelbox
attrs = mc.channelBox(channelBox, q=True, sma=True)
if attrs:
channel = controller + "." + attrs[0]
constraint = mc.listConnections(channel, type="constraint")[0]
currentTime = mc.currentTime( query=True )
# save rest pose on constraint
# mc.currentTime(currentTime-1)
constraintChannels = mc.listConnections(constraint, type="animCurve")
mc.parentConstraint(controller, constraint, edit=True, maintainOffset=True)
for i in constraintChannels:
value = mc.getAttr(mc.listConnections(i, plugs=True)[0])
setKeyframe(mc.listConnections(i, plugs=True)[0], currentTime, value)
# set key on 1 for controller
setKeyframe(channel, currentTime-1, value=0)
setKeyframe(channel, currentTime, value=1)
# mc.currentTime( currentTime )
else:
mc.warning("Select constrain channel!")
开发者ID:robertvari,项目名称:ShotManager_dev,代码行数:26,代码来源:keyConstraint.py
示例4: BindSkeletons
def BindSkeletons(source, dest, method='connect'):
'''
From 2 given root joints search through each hierarchy for child joints, match
them based on node name, then connect their trans/rots directly, or
parentConstrain them. Again cmds for speed
'''
sourceJoints = cmds.listRelatives(source, ad=True, f=True, type='joint')
destJoints = cmds.listRelatives(dest, ad=True, f=True, type='joint')
if cmds.nodeType(source) == 'joint':
sourceJoints.append(source)
if cmds.nodeType(dest) == 'joint':
destJoints.append(dest)
attrs = ['rotateX', 'rotateY', 'rotateZ', 'translateX', 'translateY', 'translateZ']
for sJnt, dJnt in MatchGivenHierarchys(sourceJoints, destJoints):
if method == 'connect':
for attr in attrs:
try:
cmds.connectAttr('%s.%s' % (sJnt, attr), '%s.%s' % (dJnt, attr), f=True)
except:
pass
elif method == 'constrain':
try:
cmds.parentConstraint(sJnt, dJnt, mo=True)
except:
pass
开发者ID:miketon,项目名称:SymLink,代码行数:28,代码来源:AnimationBinder.py
示例5: addJoint
def addJoint(side='L'):
if mc.objExists('%s_armPalm_bnd_0'%side):return
# make joint and locators
Joint = mc.createNode('joint', name='%s_armPalm_bnd_0'%side)
JointGroup = mc.group(Joint, name='%s_armPalm_bndgrp_0'%side)
FKloc = mc.spaceLocator(p=(0,0,0), name='%s_armPalmFK_loc_0'%side)[0]
IKloc = mc.spaceLocator(p=(0,0,0), name='%s_armPalmIK_loc_0'%side)[0]
# constraint
constraintNode = mc.parentConstraint(FKloc, IKloc, JointGroup)
# match position
mc.delete(mc.parentConstraint('%s_armMiddleAIK_jnt_0'%side, FKloc))
mc.delete(mc.parentConstraint('%s_armMiddleAIK_jnt_0'%side, IKloc))
# parent locator
mc.parent(FKloc, '%s_armWristFk_jnt_0'%side)
mc.parent(IKloc, '%s_armMiddleAIK_jnt_0'%side)
# make ikfk switch
reverseNode = [x.split('.')[0] for x in mc.connectionInfo('%s_armFkIk_ctl_0.FKIKBlend'%side, dfs=True) if mc.nodeType(x.split('.')[0])=='reverse'][0]
mc.connectAttr('%s.outputX'%reverseNode, '%s.%sW0'%(constraintNode[0], FKloc))
mc.connectAttr('%s_armFkIk_ctl_0.FKIKBlend'%side, '%s.%sW1'%(constraintNode[0], IKloc))
# add to bind set
mc.sets(Joint, e=True, forceElement='bind_joints_set')
# connect jointLayer
mc.connectAttr('jointLayer.drawInfo', '%s.drawOverride'%Joint)
# parent joint
mc.parent(JointGroup, '%s_armBind_org_0'%side)
开发者ID:AtonLerin,项目名称:RiggingTeamTools,代码行数:33,代码来源:addPalmBindJoint.py
示例6: cameraFrustum_build
def cameraFrustum_build(cam_shape):
#make sure a camera is loaded
if cam_shape==0:
cmds.error('no camera loaded...select a camera and load')
else:
#create frustum only if one doesnt already exist
selCamXform = cmds.listRelatives(cam_shape[0], p=1)
prefix = 'frust_'
frustumGrpName = prefix + 'camera_frustum_all_grp'
if cmds.objExists(frustumGrpName)==0:
#create main grp
frustumMainGrp = cmds.group(em=1, n=frustumGrpName);
cmds.setAttr(frustumGrpName + '.tx', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.ty', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.tz', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.rx', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.ry', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.rz', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.sx', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.sy', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.sz', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.v', lock=1, keyable=0, channelBox=0)
#create frustum geo
frustumGeo = cmds.polyCube(w=2, h=2, d=2, n=prefix + 'camera_frustum_geo')
cmds.delete(frustumGeo[0], constructionHistory=True)
cmds.parent(frustumGeo[0], frustumMainGrp)
#load plugin "nearestPointOnMesh.mll" if needed and connect
plugin = cmds.pluginInfo('nearestPointOnMesh.mll', q=1, l=1)
if plugin==0:
cmds.loadPlugin('nearestPointOnMesh.mll')
nearNodeName = prefix + 'npomNode'
npomNode = cmds.createNode('nearestPointOnMesh', n=nearNodeName)
cmds.connectAttr(frustumGeo[0] + '.worldMesh', npomNode + '.inMesh')
#create clusters
cmds.select(frustumGeo[0] + '.vtx[4:7]', r=1)
nearCluster = cmds.cluster(n=prefix + 'camera_nearFrustum_cluster')
cmds.select(frustumGeo[0] + '.vtx[0:3]', r=1)
farCluster = cmds.cluster(n=prefix + 'camera_farFrustum_cluster')
#create near/far/camera locs
cameraLoc = cmds.spaceLocator(p=(0, 0, 0), n=prefix + 'camera_loc')
cmds.parent(cameraLoc[0], frustumMainGrp)
nearLoc = cmds.spaceLocator(p=(0, 0, 0), n=prefix + 'camera_nearFrustum_loc')
cmds.move(0, 0, -1)
farLoc = cmds.spaceLocator(p=(0, 0, 0), n=prefix + 'camera_farFrustum_loc')
cmds.move(0, 0, 1)
#parent clusters under loc -- parent locs under camera loc
cmds.parent(nearCluster[1], nearLoc[0])
cmds.parent(farCluster[1], farLoc[0])
cmds.parent(nearLoc[0], cameraLoc[0])
cmds.parent(farLoc[0], cameraLoc[0])
#constrain camera loc to camera
cmds.parentConstraint(selCamXform, cameraLoc, weight=1)
return frustumGeo[0]
开发者ID:aaronfang,项目名称:personal_scripts,代码行数:60,代码来源:getFacesInsideFrustum.py
示例7: locatorOnly
def locatorOnly(self):
sel = cmds.ls(sl=True)
# Gives error if more than one object is selected.
if len(sel) > 1:
cmds.error("Too many objects selected!")
# Creates and snaps a locator to object.
elif len(sel):
tObj = sel[0]
tLoc = "{0}_tLoc".format(tObj)
LScale = cmds.floatField(LocScale, q=True, v=True)
if cmds.objExists(tLoc):
cmds.delete(tLoc)
cmds.spaceLocator(n="{0}_tLoc".format(tObj))
cmds.scale(LScale, LScale, LScale)
cmds.parentConstraint(tObj, tLoc, mo=False)
cmds.parentConstraint(tObj, tLoc, rm=True)
print LScale
# Gives error if no objects are selected.
else:
cmds.error("No objects selected!")
开发者ID:Italic-,项目名称:maya-prefs,代码行数:26,代码来源:jamTrack.py
示例8: rigBlendControl
def rigBlendControl(self, _parent):
# Move and parent blend control
rc.orientControl(self.m_blendControl, _parent)
group = rg.addGroup(self.m_blendControl, "%s_0" %(self.m_blendControl))
moveValue = -2
if self.m_isMirrored:
moveValue *= -1
cmds.setAttr("%s.t%s" %(self.m_blendControl, self.m_twistAxis), moveValue)
cmds.parentConstraint(_parent, group, mo=1)
rc.lockAttrs(
self.m_blendControl,
[
"tx",
"ty",
"tz",
"rx",
"ry",
"rz",
"sx",
"sy",
"sz",
"visibility"
],
True,
True
)
开发者ID:jaredauty,项目名称:Rigging,代码行数:26,代码来源:ArmRig.py
示例9: 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], sol='ikSplineSolver', ns=1)
cmds.rename(ik[1], '%s_%s_%s' % (self.side, 'neck', self.nc.effector))
curve = cmds.rename(ik[2], '%s_%s_%s' % (self.side, 'neck', self.nc.curve))
cmds.setAttr('%s.inheritsTransform' % curve, 0)
ik = cmds.rename(ik[0], '%s_%s_%s' % (self.side, 'neck', self.nc.ikhandle))
cmds.select(self.additional_jnts, curve)
cmds.skinCluster(tsb=True)
cmds.parent(ik, self.top_grp)
cmds.setAttr('%s.dTwistControlEnable' % ik, 1)
cmds.setAttr('%s.dWorldUpType' % ik, 4)
cmds.setAttr('%s.dWorldUpAxis' % ik, 4)
cmds.setAttr('%s.dWorldUpVectorY' % ik, -1)
cmds.setAttr('%s.dWorldUpVectorEndY' % ik, 1)
cmds.setAttr('%s.dWorldUpVectorEndZ' % ik, -1)
cmds.connectAttr('%s.worldMatrix[0]' % self.additional_jnts[0], '%s.dWorldUpMatrix' % ik, f=True)
cmds.connectAttr('%s.worldMatrix[0]' % self.additional_jnts[1], '%s.dWorldUpMatrixEnd' % ik, f=True)
self.head_grp = cmds.group(self.controls['head'])
self.head_grp = cmds.rename(self.head_grp, '%s_head_CTL_%s' % (self.side, self.nc.group))
cmds.parent(self.head_grp, self.top_grp)
self.c.move_pivot_to(self.guides['neckEnd'][0], self.guides['neckEnd'][1], self.guides['neckEnd'][2], self.head_grp)
cmds.parentConstraint(self.controls['head'], self.additional_jnts[-1], mo=True, weight=1)
cmds.orientConstraint(self.controls['head_rot'], self.result_jnts[-1], mo=True, weight=1)
开发者ID:jonntd,项目名称:Rigganator,代码行数:25,代码来源:dragonneck.py
示例10: AddSpaceObject
def AddSpaceObject(self, ControlObject, SpaceObject, SpaceSwitchName = "spaceSwitch"):
SpaceSwDic = self.GetSpaceSwitchDic( ControlObject, SpaceSwitchName = SpaceSwitchName)
EnumDic = self.AddEnumParameters([self.NameConv.RMGetAShortName(SpaceObject)],ControlObject)
Switch = cmds.shadingNode('condition', asUtility=True, name = SpaceSwitchName + "SWCondition")
cmds.connectAttr(ControlObject + "." + SpaceSwitchName, Switch + ".firstTerm")
cmds.setAttr (Switch +".secondTerm", EnumDic[self.NameConv.RMGetAShortName(SpaceObject)])
cmds.setAttr (Switch +".operation", 0)
cmds.setAttr (Switch +".colorIfTrueR", 1)
cmds.setAttr (Switch +".colorIfFalseR", 0)
if self.NameConv.RMIsNameInFormat(ControlObject):
Switch = self.NameConv.RMRenameBasedOnBaseName(ControlObject, Switch, NewName = Switch)
else:
Switch = self.NameConv.RMRenameNameInFormat(Switch)
for eachConstraint in SpaceSwDic['constraints']:
Object = SpaceSwDic['constraints'][eachConstraint]['object']
parentConstraint = cmds.parentConstraint (SpaceObject, Object, mo = True)
WA = cmds.parentConstraint (parentConstraint, q = True, weightAliasList = True)
TL = cmds.parentConstraint (parentConstraint, q = True, targetList = True)
if SpaceObject in TL:
cmds.connectAttr (Switch + ".outColorR", parentConstraint[0] + "." + WA[TL.index(SpaceObject)])
else:
print "Error, cant find spaceobject in constraint targetList"
开发者ID:rendermotion,项目名称:RMMel,代码行数:26,代码来源:RMSpaceSwitch.py
示例11: getParentConstraintDic
def getParentConstraintDic (self, parentConstraint) :
returnedDic = {'alias':{}, "object":None }
aliasDic={}
if cmds.objectType(parentConstraint)=="parentConstraint":
WA = cmds.parentConstraint (parentConstraint, q = True, weightAliasList = True)
TL = cmds.parentConstraint (parentConstraint, q = True, targetList = True)
elif cmds.objectType(parentConstraint)=="orientConstraint":
WA = cmds.orientConstraint (parentConstraint, q = True, weightAliasList = True)
TL = cmds.orientConstraint (parentConstraint, q = True, targetList = True)
elif cmds.objectType(parentConstraint)=="pointConstraint":
WA = cmds.pointConstraint (parentConstraint, q = True, weightAliasList = True)
TL = cmds.pointConstraint (parentConstraint, q = True, targetList = True)
else:
"error No constraint Type identified"
if len(WA) == len(TL):
for eachWAIndex in range(0,len(WA)):
aliasDic[WA[eachWAIndex]] = TL[eachWAIndex]
returnedDic["object"] = cmds.listConnections(parentConstraint + ".constraintRotateX")[0]
returnedDic["alias"] = aliasDic
return returnedDic
开发者ID:rendermotion,项目名称:RMMel,代码行数:25,代码来源:RMSpaceSwitch.py
示例12: closestPointOnModel
def closestPointOnModel(self , modelShape , obj):
closest_Point = []
modelShapeType = self.getObjType(modelShape)
temp = mc.createNode('transform',name=obj+'_point_temp')
mc.parentConstraint(obj,temp,mo = False)
#model type data
if modelShapeType == 'kNurbsSurface':
closest_Point = ['closestPointOnSurface' , temp+'_cpos' , 'local' , 'inputSurface']
elif modelShapeType == 'kMesh':
closest_Point = ['closestPointOnMesh' , temp+'_cpom' , 'outMesh' , 'inMesh']
#create getUV Node
closest_PointNode = mc.createNode( closest_Point[0] , name = closest_Point[1] )
mc.connectAttr( temp+'.translate' , closest_PointNode+'.inPosition' )
mc.connectAttr( modelShape + '.' + closest_Point[2] , closest_PointNode +'.' + closest_Point[3] )
#get UV
U = mc.getAttr(closest_PointNode + '.result.parameterU')
V = mc.getAttr(closest_PointNode + '.result.parameterV')
mc.delete(closest_PointNode,temp)
return {'u':U , 'v':V}
开发者ID:wangqinghuaTudou,项目名称:test,代码行数:25,代码来源:rosa_RivetTool.py
示例13: RMCreateTwist
def RMCreateTwist(self, TwistJoint, LookAtObject, NumberOfTB = 3, LookAtAxis = "Y"):
#LookAtObject = cmds.listRelatives( TwistJoint,type = "transform",children=True)[]
positionA = cmds.xform(TwistJoint ,q=True,ws=True,rp=True)
positionB = cmds.xform(LookAtObject ,q=True,ws=True,rp=True)
vectorA = om.MVector(positionA)
vectorB = om.MVector(positionB)
self.RMCreateBonesBetweenPoints(vectorA,vectorB,NumberOfTB, AlignObject = TwistJoint)
Distance = RMRigTools.RMPointDistance( TwistJoint, LookAtObject)
cmds.parentConstraint (TwistJoint,self.TwistResetJoints)
resetPoint , control = RMRigShapeControls.RMCreateBoxCtrl(self.TwistJoints[0], Xratio = .1, Yratio = .1, Zratio = .1, customSize = Distance/5 ,name = "TwistOrigin" + self.NameConv.RMGetAShortName (TwistJoint).title())
#control = self.NameConv.RMRenameBasedOnBaseName(TwistJoint , control, NewName = self.NameConv.RMGetAShortName(control))
#resetPoint = self.NameConv.RMRenameBasedOnBaseName(TwistJoint , resetPoint, NewName = self.NameConv.RMGetAShortName(resetPoint))
sign = 1
MoveDistance = Distance/5
if "-" in LookAtAxis:
sign = -1
if "Z" in LookAtAxis or "z" in LookAtAxis:
MoveList = [0,0, MoveDistance * sign]
WUV = [0,0,sign]
elif "Y" in LookAtAxis or "y" in LookAtAxis:
MoveList = [0,MoveDistance * sign,0 ]
WUV = [0,sign,0]
cmds.xform( resetPoint, os = True, relative=True, t = MoveList)
cmds.aimConstraint( LookAtObject,self.TwistJoints[0], aim = [1,0,0], worldUpVector = [0,0,1], worldUpType = "object", worldUpObject = control)
TwistJointDivide = cmds.shadingNode( "multiplyDivide", asUtility = True, name = "TwistJoint" + self.NameConv.RMGetAShortName( TwistJoint).title())
TwistJointDivide = self.NameConv.RMRenameBasedOnBaseName( TwistJoint , TwistJointDivide, NewName = self.NameConv.RMGetAShortName( TwistJointDivide))
TwistAddition = cmds.shadingNode( "plusMinusAverage", asUtility = True, name = "TwistJointAdd" + self.NameConv.RMGetAShortName( TwistJoint).title())
TwistAddition = self.NameConv.RMRenameBasedOnBaseName( TwistJoint , TwistAddition, NewName = self.NameConv.RMGetAShortName( TwistAddition))
NegativeLookAtRotation = cmds.shadingNode( "multiplyDivide", asUtility = True, name = "NegativeLookAtRotation" + self.NameConv.RMGetAShortName( TwistJoint).title())
NegativeLookAtRotation = self.NameConv.RMRenameBasedOnBaseName( TwistJoint , NegativeLookAtRotation, NewName = self.NameConv.RMGetAShortName( NegativeLookAtRotation))
cmds.connectAttr( LookAtObject + ".rotateX", NegativeLookAtRotation + ".input1X")
cmds.setAttr(NegativeLookAtRotation + ".input2X", -1 )
cmds.setAttr(NegativeLookAtRotation + ".operation", 1 )
cmds.connectAttr(self.TwistJoints[0]+".rotateX", TwistAddition + ".input1D[0]")
cmds.connectAttr( NegativeLookAtRotation + ".outputX", TwistAddition + ".input1D[1]")
cmds.connectAttr(TwistAddition + ".output1D", TwistJointDivide + ".input1X")
#cmds.connectAttr(self.TwistJoints[0]+".rotateX", TwistJointDivide + ".input1X") in this case the rotation of the lookatNode was not affecting
cmds.setAttr(TwistJointDivide + ".input2X", -(len(self.TwistJoints) - 1))
cmds.setAttr(TwistJointDivide + ".operation", 2 )
for eachJoint in self.TwistJoints[1:]:
cmds.connectAttr(TwistJointDivide+".outputX", eachJoint + ".rotateX")
self.TwistControlResetPoint = resetPoint
self.TwistControl = control
开发者ID:rendermotion,项目名称:RMMel,代码行数:60,代码来源:RMTwistJoints.py
示例14: createArmSwitches
def createArmSwitches(pairs, instance):
parents = []
enumvals = []
connodes = []
for p in range(len(pairs)):
parents.append(pairs[p][0])
con = cmds.shadingNode("condition", asUtility=True, n=instance + pairs[p][0] + 'Switch_CON')
connodes.append(con)
cmds.setAttr(con+'.secondTerm', p)
enumvals.append(pairs[p][2])
ctrlparent = cmds.listRelatives(pairs[0][1], p=True)[0]
switchgrpname = pairs[0][1].replace('_GRP', '_SWITCH' )
sgrp = cmds.group(n=switchgrpname, em=True)
tc = cmds.parentConstraint(pairs[0][1], sgrp, mo=False)
cmds.delete(tc)
cmds.parent(sgrp, ctrlparent)
cmds.parent(pairs[0][1], sgrp)
parentcon = cmds.parentConstraint(parents[0], parents[1], parents[2], parents[3], parents[4], sgrp, mo=True)
cmds.addAttr(pairs[p][2], at='enum', en="World:Root:COG:Pelvis:Chest:", shortName="switch", longName="switch", k=True)
for c in range(len(connodes)):
cmds.setAttr(connodes[c]+'.colorIfTrueR', 1)
cmds.setAttr(connodes[c]+'.colorIfTrueG', 1)
cmds.setAttr(connodes[c]+'.colorIfTrueB', 1)
cmds.setAttr(connodes[c]+'.colorIfFalseR', 0)
cmds.setAttr(connodes[c]+'.colorIfFalseG', 0)
cmds.setAttr(connodes[c]+'.colorIfFalseB', 0)
cmds.connectAttr(pairs[0][2]+'.switch', connodes[c]+'.firstTerm')
cmds.connectAttr(connodes[c]+'.outColorR', parentcon[0] + '.' + pairs[c][0] + 'W' + str(c))
开发者ID:RiggingDojo,项目名称:AnomaliaRigging,代码行数:31,代码来源:utils.py
示例15: RMRedistributeConstraint
def RMRedistributeConstraint(self,ListOfDrivers, ListOfConstrained, MaxInfluences, KeepBorders = True, ConstraintType = "parent"):
DeltaMaxInfluence = 1/(float (len(ListOfDrivers))-1)
CentersControlDic = {}
for i in range (0,len( ListOfDrivers)):
CentersControlDic[ListOfDrivers[i]] = ( DeltaMaxInfluence*i)
pprint.pprint (CentersControlDic)
DeltaPositionConstrained = float(1/(float(len(ListOfConstrained))-1))
PositionConstDic = {}
for i in range(0,len( ListOfConstrained)):
PositionConstDic[ListOfConstrained[i]] = (DeltaPositionConstrained*i)
pprint.pprint (PositionConstDic)
reach = MaxInfluences * DeltaMaxInfluence
for eachConstrained in ListOfConstrained:
for eachDriver in ListOfDrivers:
weight = self.RMGaussCosine( PositionConstDic [ eachConstrained ], CentersControlDic [ eachDriver ], reach )
if weight > 0:
if ConstraintType == "parent":
cmds.parentConstraint(eachDriver, eachConstrained , weight = weight,mo = True)
elif ConstraintType == "point":
cmds.pointConstraint(eachDriver, eachConstrained , weight = weight,mo = True)
elif ConstraintType == "orient":
cmds.orientConstraint(eachDriver, eachConstrained , weight = weight,mo = True)
else:
print "not valid costraintType requested, valid types are point, parent, or orient"
开发者ID:rendermotion,项目名称:RMMel,代码行数:30,代码来源:RMSpine.py
示例16: tentacleRig
def tentacleRig():
sel = cmds.ls(sl=1)
if sel:
ns = sel[0].split(':')[0]
side = sel[0].split(':')[1][0]
g = cmds.group(n=plc.getUniqueName('__TENTACLERIG__'), em=True)
macros = tentacleMacro(ns, side)
micros = tentacleMicro(ns, side)
i = 0
j = 0
for macro in macros:
if i != 3:
# macroN = tentacleMacroCt(macro)
# cmds.parent(macroN, g)
microN = tentacleMicroCt(micros[j], macro)
cmds.parent(microN, g)
if i != 3:
macroFake = tentacleCt(parents=[macros[i], macros[i + 1]], j=j, ns=ns, side=side)
cmds.parent(macroFake, g)
i = i + 1
j = j + 3
# clean up
if len(sel) == 2:
cmds.parentConstraint(sel[1], g)
p = plc.assetParent(sel[0])
cmds.parent(g, p)
else:
message('Select an object or 2')
开发者ID:boochos,项目名称:work,代码行数:28,代码来源:animRig_lib.py
示例17: 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")
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:32,代码来源:dpSingle.py
示例18: CreateFingerSquareRig
def CreateFingerSquareRig(self,Finger):
if self.NameConv.RMGetFromName(Finger[0],"Side")=="LF":
sideVariation = 1
else:
sideVariation = -1
BoxResetPoint , BoxControl = RMRigShapeControls.RMCreateBoxCtrl(Finger[len(Finger)-1], ParentBaseSize = True, Xratio = .5 ,Yratio = .5 ,Zratio = .5)
self.RMaddFinguerControls(BoxControl)
cmds.makeIdentity(BoxControl, apply = True , r = False, t = True, s = True, n = 0)
cmds.parentConstraint(Finger[len(Finger)-1],BoxResetPoint)
RMRigTools.RMLockAndHideAttributes(BoxControl,"0000000000")
RMRigTools.RMConnectWithLimits (BoxControl + ".MidUD", Finger[0] + ".rotateY", [[-10,100],[0,0],[10,-100]])
RMRigTools.RMConnectWithLimits (BoxControl + ".MidLR", Finger[0] + ".rotateZ", [[-10,sideVariation * 120],[0,0],[10,sideVariation * -127]])
RMRigTools.RMConnectWithLimits (BoxControl + ".MidTwist", Finger[0] + ".rotateX" ,[[-10,sideVariation * 90],[0,0],[10,sideVariation * -90]])
index = 1
for eachjoint in range(0,len(Finger)-1):
RMRigTools.RMConnectWithLimits (BoxControl + ".UD" + str(index), Finger[eachjoint] + ".rotateY", [[-10,100],[0,0],[10,-100]])
RMRigTools.RMConnectWithLimits (BoxControl + ".LR" + str(index), Finger[eachjoint] + ".rotateZ", [[-10,sideVariation * 120],[0,0],[10,sideVariation * -127]])
RMRigTools.RMConnectWithLimits (BoxControl + ".Twist" + str(index), Finger[eachjoint] + ".rotateX" ,[[-10, sideVariation * 90],[0,0],[10, sideVariation * -90]])
index += 1
self.fingerControlsReset.append(BoxResetPoint)
self.fingerContols.append(BoxControl)
开发者ID:rendermotion,项目名称:RMMel,代码行数:26,代码来源:RMGenericHandRig.py
示例19: on_actionStartMove_triggered
def on_actionStartMove_triggered(self, args=None):
if args==None:return
toMoveOBJ = str(self.MovedOBJLineEdit.text())
toKeepOBJ = str(self.KeepedOBJLineEdit.text())
if not mc.objExists(toMoveOBJ) or not mc.objExists(toKeepOBJ):return
if toMoveOBJ == toKeepOBJ:return
self.ConstraintDT = {}
self.ConstraintLocators = []
for Jnt in (toKeepOBJ, toMoveOBJ):
OldConstraintNode = [x for x in mc.listRelatives(Jnt, c=True, path=True) or [] if mc.nodeType(x).endswith('Constraint')]
for OCSN in OldConstraintNode:
ConstraintType = mc.nodeType(OCSN)
ConstraintOBJ = eval('mc.%s("%s", q=True, tl=True)'%(ConstraintType, OCSN))
self.ConstraintDT.setdefault(Jnt, {})['type'] = ConstraintType
self.ConstraintDT.setdefault(Jnt, {})['ConsOBJ'] = ConstraintOBJ
mc.delete(OCSN)
Loc = mc.spaceLocator(p=(0,0,0))
mc.delete(mc.parentConstraint(Jnt, Loc))
ConstraintNode = mc.parentConstraint(Loc[0], Jnt)
self.ConstraintLocators.append(Loc[0])
self.ConstraintLocators.append(ConstraintNode[0])
开发者ID:AtonLerin,项目名称:RiggingTeamTools,代码行数:30,代码来源:ChangeOBJpivot.py
示例20: 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)
开发者ID:SplineO,项目名称:cmt,代码行数:27,代码来源:orientjoints.py
注:本文中的maya.cmds.parentConstraint函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论