当前位置: 首页>>代码示例>>Python>>正文


Python cmds.pointConstraint函数代码示例

本文整理汇总了Python中maya.cmds.pointConstraint函数的典型用法代码示例。如果您正苦于以下问题:Python pointConstraint函数的具体用法?Python pointConstraint怎么用?Python pointConstraint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pointConstraint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setSpring

 def setSpring(self,*args):
     
     self.springName="spring"
 
     #create a set to put all of the spring elements inside
     self.springSetName="spring_SET"
     if mc.objExists(self.springSetName):
         print (self.springSetName + " exists.")
     else:
         mc.sets(name=self.springSetName)
     
     #create guides
     self.set_connector(self.springName)
         
     #create radius circle
     self.radCntrl=mc.circle(name="radius_CTRL",c=(0,0,0), nr=(0,1,0), 
                             sw=360, r=3, d=3, ut=0, tol=0.01, s=8, ch=1)
     #create springRadius attribute
     mc.addAttr(self.radCntrl, sn="sr", ln="springRadius", k=1, defaultValue=3.0, min=0.1, max=15)
     
     #connect the springRadius attribute to the circle
     mc.connectAttr("radius_CTRL.springRadius", "{0}.radius".format(self.radCntrl[1]))
     
     #position radCntrl between locators and aim
     
     mc.pointConstraint(self.baseLoc, self.topLoc,self.radCntrl[0])
     mc.aimConstraint(self.topLoc,self.radCntrl[0],aimVector=(0,1,0))
     
     self.lockHide(self.radCntrl[0])
     
     #create tmp group for easy deletion
     mc.select(self.baseLoc,self.topLoc,self.conCurve,self.radCntrl)
     self.selSpringObjs=mc.ls(sl=True,type="transform")
     
     self.createTmp(self.selSpringObjs)
开发者ID:eyalMDM,项目名称:MDMthesis,代码行数:35,代码来源:tgpMechanix.py

示例2: 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

示例3: _create_constraints

    def _create_constraints(self, joints, side):
        """Creates the constraints between the hydraulics pieces.
        @param joints: the joints
        @param side: the side
        @type joints: list
        @type side: String

        """
        name = joints[0].split('_start_%s' % self.nc.joint)[0]
        world_up_object = cmds.spaceLocator(n='%s_%s' % (name, self.nc.locator))[0]
        cmds.setAttr('%s.v' % world_up_object, 0)
        self.c.snap_a_to_b(world_up_object, joints[0])
        ac1 = cmds.aimConstraint(joints[0], joints[-1], mo=False, weight=1,
                                 aimVector=(1, 0, 0), upVector=(0, 1, 0),
                                 worldUpType='object', worldUpObject=world_up_object)[0]
        ac2 = cmds.aimConstraint(joints[-1], joints[0], mo=False, weight=1,
                                 aimVector=(1, 0, 0), upVector=(0, 1, 0),
                                 worldUpType='object', worldUpObject=world_up_object)[0]
        cmds.delete(ac1, ac2)
        self._place_world_up_object(world_up_object, joints[0], joints[-1], side)
        ac1 = cmds.aimConstraint(joints[0], joints[-1], mo=False, weight=1,
                                 aimVector=(1, 0, 0), upVector=(0, 1, 0),
                                 worldUpType='object', worldUpObject=world_up_object)[0]
        ac2 = cmds.aimConstraint(joints[-1], joints[0], mo=False, weight=1,
                                 aimVector=(1, 0, 0), upVector=(0, 1, 0),
                                 worldUpType='object', worldUpObject=world_up_object)[0]
        if len(joints) == 3:
            cmds.aimConstraint(joints[-1], joints[1], mo=False, weight=1)
            cmds.pointConstraint(joints[0], joints[-1], joints[1], mo=False, weight=1)
        # END if
        return world_up_object
开发者ID:jonntd,项目名称:Rigganator,代码行数:31,代码来源:hydraulics.py

示例4: primeControl

def primeControl(driver, driven):	
	'''
	# Priming a control
	
	Return driver, grp, driven
	'''
	
	# Group needs to be created
	# Name group after control icon that is going to be created.
	grpNamePieces = driven.split("_")
	if( len(grpNamePieces) > 1 ): 
	    grpNamePieces = grpNamePieces[0:-1]
	grpNamePieces.append("grp")
	grpName = "_".join(grpNamePieces)
	grp = cmds.group( name=grpName, em=True, world=True )
	pc = cmds.pointConstraint( driver, grp )
	oc = cmds.orientConstraint( driver, grp )
	cmds.delete(pc, oc)
	# Option to snap control to position.
	pc = cmds.pointConstraint( driver, driven )
	
	cmds.delete( pc )
	cmds.parent( driven, grp )
	cmds.makeIdentity( apply=True, t=1, r=1, s=1, n=0 )
	
	# Position option to constrain driver to driven
	# Options: Point, Orient, Parent, and None

	return [driver, grp, driven]
开发者ID:creuter23,项目名称:fs-tech-artist,代码行数:29,代码来源:rigTools.py

示例5: 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

示例6: joint

def joint(side, lowerJoint, upperJoint, useSphere=0, sharedUpper=0, sharedLower=0, show=1, heightScale=1):
    name = lowerJoint + "_" + upperJoint

    upperName = "SKEL_"
    if sharedUpper == 0:
        upperName += side + "_"
    upperName += upperJoint

    lowerName = "SKEL_"
    if sharedLower == 0:
        lowerName += side + "_"
    lowerName += lowerJoint

    print name
    cmds.spaceLocator(name="%s_%s" % (side, name))
    cmds.pointConstraint(lowerName, "%s_%s" % (side, name))
    cmds.pointConstraint(upperName, "%s_%s" % (side, name))
    cmds.aimConstraint(upperName, "%s_%s" % (side, name))
    if useSphere:
        cmds.sphere(name="%s_%s_C" % (side, name), radius=1)
    else:
        cmds.cylinder(name="%s_%s_C" % (side, name), radius=0.5, heightRatio=6 * heightScale)

    cmds.setAttr("%s_%s_C.doubleSided" % (side, name), 0)
    if show == 0:
        cmds.setAttr("%s_%s_C.primaryVisibility" % (side, name), 0)

        # cmds.rotate( 0, 0, 90, '%s_FOREARM_C' % (side) )
        # cmds.makeIdentity( '%s_FOREARM_C' % (side), apply = 1, rotate = 1 )
    cmds.select("%s_%s" % (side, name), "%s_%s_C" % (side, name))
    cmds.parentConstraint()
    return
开发者ID:torbensko,项目名称:Kinect-to-Maya-motion-capture,代码行数:32,代码来源:mayaKinectAutoRig.py

示例7: displayConnect_arrow

def displayConnect_arrow( _obj ):
	# 타겟 오브젝트
    _pointA = _obj[0]
    _pointB = _obj[1]

	# 라인생성
    _createNode = cmds.createNode('annotationShape')
    _listRelatives = cmds.listRelatives( _createNode, parent=True )
    _annotation = [_listRelatives[0], _createNode]
    print _annotation

    _loc = cmds.spaceLocator()
    _listRelatives = cmds.listRelatives( _loc[0], s=True )
    _locator = [ _loc[0], _listRelatives[0] ]

    cmds.connectAttr( _locator[1]+'.worldMatrix[0]', _annotation[1]+'.dagObjectMatrix[0]')

	# pointCurveConstraint로 생성된 로케이터를 타겟 오브젝트에 붙임
    cmds.pointConstraint( _pointA, _annotation[0])
    cmds.pointConstraint( _pointB, _locator[0])

	# 로케이터 가림
    cmds.setAttr (_locator[1]+'.visibility', 0)

	# return
    return [_annotation[0], _locator[0]]
开发者ID:kyuhoChoi,项目名称:mayaTools,代码行数:26,代码来源:Gun_Tools.py

示例8: _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))
开发者ID:jonntd,项目名称:Rigganator,代码行数:35,代码来源:robothand.py

示例9: setupIK

 def setupIK(self):
     #Create shoulder 
     self.m_shoulderCtrl = cmds.spaceLocator(
         n=self.m_joints.m_shoulder.replace("_JNT", "_LOC")
         )[0]
     # Add to controls
     rc.addToControlDict(self.m_allControls, "%s_IKShoulder" %(self.m_baseName), self.m_shoulderCtrl)
     rc.addToLayer(self.m_sceneData, "hidden", self.m_shoulderCtrl)
     rc.orientControl(self.m_shoulderCtrl, self.m_joints.m_shoulder)
     rg.add3Groups(self.m_shoulderCtrl, ["_SDK", "_CONST", "_0"])
     cmds.parent(self.m_shoulderCtrl+"_0", self.m_group, r=1)
     cmds.pointConstraint(
         self.m_shoulderCtrl, 
         self.m_joints.m_shoulder, 
         mo=1
         )
     desiredName = self.m_wristCtrl.replace("_CTRL", "_IK")
     self.m_ikHandle = cmds.ikHandle(
         n = desiredName, 
         sj = self.m_joints.m_shoulder, 
         ee = self.m_joints.m_wrist, 
         sol = "ikRPsolver", 
         see = True
         )[0]
     # deselect so we don't get errors
     cmds.select(d=1)
     rc.addToLayer(self.m_sceneData, "hidden", [self.m_ikHandle])
     cmds.parent(self.m_ikHandle, self.m_wristCtrl)
     self.setupPoleVec()
开发者ID:jaredauty,项目名称:Rigging,代码行数:29,代码来源:IKArm.py

示例10: nullMeasurementRig

 def nullMeasurementRig(self,name):
 
     #finds starting position and orientation
     startPos = MeasuringTool.getPointLocation(self.objectStart)
     startOrient = cmds.xform(self.objectStart,q = True, ws = True, rotation = True)
     
     #create parent group
     parentGroup = cmds.group(empty = True, name = '%s_Stretch_Group'%name)
      
     #create main null
     mainNull = cmds.group(empty = True, parent  = parentGroup,name = '%s_Main_Null'%name)
     
     #creates starting null
     startNull = cmds.group(empty = True,parent = parentGroup, name = '%s_Start_Null'%(name))
     
     #creates end null
     endNull = cmds.group(empty = True, parent = startNull, name = '%s_End_Null'%(name))
     
     cmds.move(startPos[0], startPos[1], startPos[2],parentGroup)
     cmds.rotate(startOrient[0],startOrient[1],startOrient[2],parentGroup)
     
     #finds end location
     pointDistance = self.getPointDistanceBetween()
     length = MeasuringTool.getVectorLength(pointDistance)   
     cmds.move(length,0,0,endNull, a = True, os = True)
     cmds.move(length,0,0,mainNull, a = True, os = True)
     
     #create constraints
     cmds.aimConstraint(mainNull,startNull,aim = (1,0,0))
     cmds.pointConstraint(mainNull,endNull)
     
     return [startNull,endNull,mainNull,parentGroup]
开发者ID:Owacle,项目名称:maya-toolbelt,代码行数:32,代码来源:MeasuringLib.py

示例11: aimRig

    def aimRig(self,name):
    
        #query start location and orient
        startPosition = MeasuringTool.getPointLocation(self.objectStart)
        startOrient = MeasuringTool.getWorldEulerRotation(self.objectStart)
        
        
        #create locators
        aimLoc = cmds.spaceLocator(n = '%s_Aim_AimVector_Loc'%(name))
        upLoc = cmds.spaceLocator(n = '%s_Aim_UpVector_Loc'%(name))
        tgt = cmds.spaceLocator(n = '%s_Aim_Target_Loc'%(name))

        #create hierarchy
        posNull = cmds.group(aimLoc[0],upLoc[0],tgt[0],n = '%s_Aim_Pos_Null'%(name))

        cmds.move(startPosition[0],startPosition[1],startPosition[2],posNull)
        cmds.rotate(startOrient[0],startOrient[1],startOrient[2],posNull)
        
        #find vector length
        distance = self.getPointDistanceBetween()
        length = MeasuringTool.getVectorLength([distance[0],distance[1],distance[2]])
    
        #move and apply constraints to target
        cmds.move(length,0,0,tgt, a = True, os = True)
        cmds.move(0,0,10,upLoc[0],os = True)
        cmds.parentConstraint(self.objectStart,posNull)
        cmds.pointConstraint(self.objectEnd,tgt[0])
        cmds.aimConstraint(tgt,aimLoc, aimVector = (1,0,0), upVector = (0,0,1), worldUpType = "object", worldUpObject = upLoc[0])
开发者ID:Owacle,项目名称:maya-toolbelt,代码行数:28,代码来源:MeasuringLib.py

示例12: create_controls

    def create_controls(self):
        """Create controls"""

        # Make duplicate joint chain
        self._duplicate_joints()

        # Create ikHandle
        self.create_ik()
        
        # Create control
        ik_ctl = Control(self.position, self.description, 0)
        ik_ctl.create()

        # Style and lock attrs
        ik_ctl.set_style("cube")
        ik_ctl.lock_scales()

        # Append control
        self.controls[ik_ctl.name] = ik_ctl
        self.ik_ctl = ik_ctl

        # Create base null
        self.base_null = cmds.createNode("transform", name=name.set_suffix(ik_ctl.name, "baseNull"))
        xform.match_translates(self.base_null, self.ik_joints[0])
        cmds.pointConstraint(self.base_null, self.ik_joints[0], mo=True)
        self.setups.append(self.base_null)


        return self.controls
开发者ID:eddiehoyle,项目名称:link,代码行数:29,代码来源:ik.py

示例13: connect_ikfk

    def connect_ikfk(self):
        for fk_key, fk_ctl in self.fk.controls.items():

            con = fk_ctl.constraint
            rev = cmds.createNode("reverse")
            cmds.connectAttr("%s.fkik" % self.settings_node, "%s.inputX" % rev)

            aliases = cmds.parentConstraint(con, wal=True, q=True)
            
            cmds.connectAttr("%s.fkik" % self.settings_node, "%s.%s" % (con, aliases[0]))
            cmds.connectAttr("%s.outputX" % rev, "%s.%s" % (con, aliases[1]))

            # Control visibility
            cmds.setAttr("%s.visibility" % fk_ctl.ctl, l=False)
            cmds.connectAttr("%s.outputX" % rev, "%s.visibility" % fk_ctl.ctl)

        for ik_key, ik_ctl in self.ik.controls.items():
            cmds.setAttr("%s.visibility" % ik_ctl.ctl, l=False)
            cmds.connectAttr("%s.fkik" % self.settings_node, "%s.visibility" % ik_ctl.ctl)

        cmds.connectAttr("%s.fkik" % self.settings_node, "%s.visibility" % self.ik.anno)


        # Connect base Fk control
        cmds.pointConstraint(self.ik.base_null, self.fk.fk_joints[0], mo=True)
        cmds.connectAttr("%s.fkik" % self.settings_node, "%s.ikBlend" % self.ik.ik)
开发者ID:eddiehoyle,项目名称:link,代码行数:26,代码来源:ikfk.py

示例14: makeSpring

    def makeSpring(self,*args):
        
        
        self.springRadius=mc.getAttr("{0}.springRadius".format(self.radCntrl[0]))
        
        #get diameter (width)
        self.upWidth=self.springRadius*2
        
        #create base spring mesh using polyHelix
        self.springBase=mc.polyHelix(c=20,h=4,w=self.upWidth, r=0.2,sa=24,sco=24,
                                     sc=0,ax=(0,1,0),rcp=0,cuv=3,ch=1,
                                     name="springGeo")
        
        mc.pointConstraint(self.baseLoc,self.topLoc,self.springBase[0])
        mc.aimConstraint(self.topLoc,self.springBase[0],aimVector=(0,1,0))
        
        #connect height attribute of helix to distance node
        mc.connectAttr("{0}.distance".format(self.dNode),"{0}.height".format(self.springBase[1]),  force=True)
        
        mc.delete(self.radCntrl)
       
        mc.select(self.baseLoc,self.topLoc,self.conCurve,self.springBase)
        #select all spring parts        
        self.selection=mc.ls(sl=True)

        #loop through the parts and rename them accordingly    
        for x in self.selection:
            mc.rename(x,(x+"_#"))
    
        #create a group for the springs
        self.springGrp=mc.group(name="spring_GRP_#")
        #delete tmp group
        mc.delete(self.tmpGrp)
        #add GRP elements to set
        mc.sets(self.springGrp, add=self.springSetName)
开发者ID:eyalMDM,项目名称:MDMthesis,代码行数:35,代码来源:tgpMechanix.py

示例15: rigArm

    def rigArm(self, *args):
        basicFilter = "*.json"
        fileName = cmds.fileDialog2(fileFilter=basicFilter, dialogStyle=2, fm=1, okc='Load')

        # Read the Json file
        # Call on the json_utils readJson method.
        data = json_utils.readJson(fileName)
        info = json.loads( data )

        self.Rig_Info['fkJoints'] = rig_utils.createJointChain(info, 'fkj')
        self.Rig_Info['ikJoints'] = rig_utils.createJointChain(info, 'ikj')
        self.Rig_Info['rigJoints'] = rig_utils.createJointChain(info, 'rigj')

        # Setup the ik rig
        ctrlFile = 'C:/Users/Griffy/Documents/GitHub/Python101/rigging/controls/HandControl.ma'
        rig_utils.importControlObject(ctrlFile)
        self.Rig_Info['ikInfo'] = rig_utils.createIk(self.Rig_Info['ikJoints'])

        # Align the control to the last ik joint
        tmpConstraint = cmds.parentConstraint(self.Rig_Info['ikJoints'][2], 'grp_control', mo=False)
        cmds.delete(tmpConstraint)
        # Rename the control
        cmds.rename('grp_control', 'grp_ikArmCtrl')
        cmds.rename('control', 'ikArmCtrl')
        # Constrain the ikHandle to the control
        cmds.pointConstraint('ikArmCtrl', self.Rig_Info['ikInfo'][0])

        # Make the fk controls

        # Connect the fk, ik, and rig ikJoints
        for i in range(len(self.Rig_Info['rigJoints'])):
        	switchPCon = cmds.parentConstraint(self.Rig_Info['ikJoints'][i], self.Rig_Info['rigJoints'][i], mo=True)
        	cmds.parentConstraint(self.Rig_Info['fkJoints'][i], self.Rig_Info['rigJoints'][i], mo=True)
        	print switchPCon
开发者ID:RiggingDojo,项目名称:Python101_2014,代码行数:34,代码来源:rig_arm.py


注:本文中的maya.cmds.pointConstraint函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。