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


Python cmds.parent函数代码示例

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


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

示例1: 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  
开发者ID:griffinanimator,项目名称:RG_TOOLS,代码行数:34,代码来源:Utils_Widget.py

示例2: create

    def create(self, parent_transform, style):
        """Create shape"""

        self.parent = parent_transform

        # Add style
        curve_data = Style()[style]
        for curve in curve_data:
            temp = cmds.curve(name="temp_curve", d=1, p=curve['points'], k=curve['knot'])

            # Parent curve under transform
            shapes = cmds.listRelatives(temp, shapes=True)
            for shape_index, shape in enumerate(shapes):
                cmds.parent(shape, parent_transform, shape=True, r=True)

                # Rename shape to be tidy
                new_shape = cmds.rename(shape, "%s%s" % (self.name, shape_index))
                self.nodes.append(new_shape)

            # Remove temp transform
            cmds.delete(temp)

        # Set colors
        self.set_color(name.get_position(self.parent))

        # Match values
        self.scale_shapes(self.scale)
        self.rotate_shapes(self.rotate)

        # Clear selection
        cmds.select(cl=True)
开发者ID:eddiehoyle,项目名称:link,代码行数:31,代码来源:shape.py

示例3: setupIKCtrl

    def setupIKCtrl(self, x, IKHandle):

        ############# MODIFY FOR INHERITANCE  #############
        side = self.prefixList[x]
        thisChain = self.IKChains[x]

        #create a control for the ik
        name = "%s_%s_IK_CTRL"%(side, self.limbName)
        if x==0:
            IKCtrl = rig.createControl(name, "cube", self.jAxis1, "blue")
        if x==1:
            IKCtrl = rig.createControl(name, "cube", self.jAxis1, "red")
        self.IKCtrls.append(IKCtrl)
        #strip to rotate and translate
        rig.stripToRotateTranslate(IKCtrl)

        #G.O. control
        rig.groupOrient(thisChain[2], IKCtrl, self.groupSuffix)

        #orient constraint joint 2 (wrist ankle) to control
        cmds.orientConstraint(IKCtrl, thisChain[2])

        #parent ik handle to control
        cmds.parent(IKHandle, IKCtrl)

        return IKCtrl
开发者ID:zethwillie,项目名称:python_rigger,代码行数:26,代码来源:baseLimb.py

示例4: set_knee_IK

def set_knee_IK():
    # メッセージ
    cmds.inViewMessage(amg="<hl>「指のコントローラー設置」</hl>を押してください。", pos="midCenter", fade=True, fit=1, fst=4000, fts=20)
    # 座標取得
    positionR = cmds.xform("Knee_R", q=True, ws=True, t=True)
    locatorNameR = "Knee_R_Locator"
    # ロケーター設置
    cmds.spaceLocator(p=(positionR[0], positionR[1], positionR[2] + 3.8), n=locatorNameR)
    knee_ik_add("Hip_R", "Ankle_R", "Knee_R_Effector", positionR, locatorNameR)

    # 座標取得
    positionL = cmds.xform("Knee_L", q=True, ws=True, t=True)
    locatorNameL = "Knee_L_Locator"
    # ロケーター設置
    cmds.spaceLocator(p=(positionL[0], positionL[1], positionL[2] + 3.8), n=locatorNameL)
    knee_ik_add("Hip_L", "Ankle_L", "Knee_L_Effector", positionL, locatorNameL)

    # つま先のIK実行
    toe_ik_add("Ankle_R", "MiddleToe2_R", "Ankle_R_Effector")
    toe_ik_add("Ankle_L", "MiddleToe2_L", "Ankle_L_Effector")

    # 足のコントローラー、 座標取得
    toePositionR = cmds.xform("MiddleToe1_R", q=True, ws=True, t=True)
    toePositionL = cmds.xform("MiddleToe1_L", q=True, ws=True, t=True)
    foot_controller("foot_R_controller", toePositionR[0])
    foot_controller("foot_L_controller", toePositionL[0])

    # コントローラー内にエフェクター移動
    cmds.parent("Ankle_L_Effector", "foot_L_controller")
    cmds.parent("Knee_L_Effector", "foot_L_controller")
    cmds.parent("Ankle_R_Effector", "foot_R_controller")
    cmds.parent("Knee_R_Effector", "foot_R_controller")

    # 親子関係移動
    cmds.parent("Knee_R_Locator", "Knee_L_Locator", "foot_R_controller", "foot_L_controller", "main_controller")
开发者ID:akkey,项目名称:maya,代码行数:35,代码来源:LightSkeleton.py

示例5: buildAnnotation

def buildAnnotation( obj, text='' ):
	'''
	like the distance command above, this is a simple wrapper for creating annotation nodes,
	and having the nodes you actually want returned to you.  whoever wrote these commands
	should be shot.  with a large gun

	returns a 3 tuple containing the start transform, end transform, and annotation shape node
	'''
	obj = str( obj )  #cast as string just in case we've been passed a PyNode instance

	rand = random.randint
	end = spaceLocator()[ 0 ]
	shape = annotate( end, p=(rand(0, 1000000), rand(1000000, 2000000), 2364), tx=text )

	start = listRelatives( shape, p=True, pa=True )[ 0 ]
	endShape = listRelatives( end, s=True, pa=True )[ 0 ]

	delete( parentConstraint( obj, end ) )
	for ax in Axis.AXES[ :3 ]:
		setAttr( '%s.t%s' % (start, ax), 0 )

	setAttr( '%s.v' % endShape, 0 )
	setAttr( '%s.v' % endShape, lock=True )
	cmd.parent( end, obj )

	return start, end, shape
开发者ID:BGCX261,项目名称:zootoolbox-git,代码行数:26,代码来源:rigUtils.py

示例6: create_ik_arm_stretch

 def create_ik_arm_stretch(self):
     """Creates the IK stretch setup."""
     arm_dist, start_loc, end_loc = self.c.distance_node(self.guides['upperArm'], self.guides['hand'])
     arm_dist = cmds.rename(arm_dist, '%s_%s_%s' % (self.side, 'arm', self.nc.distance))
     start_loc = cmds.rename(start_loc, '%s_%s_%s' % (self.side, 'armLengthStart', self.nc.locator))
     end_loc = cmds.rename(end_loc, '%s_%s_%s' % (self.side, 'armLengthEnd', self.nc.locator))
     cmds.parent(end_loc, self.controls['handik'])
     cmds.parent(arm_dist, self.top_grp)
     driver = '%sShape.distance' % arm_dist
     if self.side == 'R':
         mult = cmds.shadingNode('multiplyDivide', asUtility=True)
         mult = cmds.rename(mult, '%s_%s_stretch_negative_MDN' % (self.side, 'arm'))
         cmds.connectAttr('%sShape.distance' % arm_dist, '%s.input1X' % mult, f=True)
         cmds.setAttr('%s.input2X' % mult, -1)
         driver = '%s.outputX' % mult
     # END if
     upper_arm_len = cmds.getAttr('%s.tx' % self.ik_jnts[1])
     fore_arm_len = cmds.getAttr('%s.tx' % self.ik_jnts[2])
     sum_len = upper_arm_len + fore_arm_len
     cmds.setDrivenKeyframe('%s.translateX' % self.ik_jnts[1], cd=driver,
                            dv=sum_len, itt='linear', ott='linear')
     cmds.setDrivenKeyframe('%s.translateX' % self.ik_jnts[1], cd=driver,
                            dv=sum_len*2, v=upper_arm_len*2, itt='linear', ott='linear')
     cmds.setDrivenKeyframe('%s.translateX' % self.ik_jnts[2], cd=driver,
                            dv=sum_len, itt='linear', ott='linear')
     cmds.setDrivenKeyframe('%s.translateX' % self.ik_jnts[2], cd=driver,
                            dv=sum_len*2, v=fore_arm_len*2, itt='linear', ott='linear')
     cmds.setAttr('%s_translateX.postInfinity' % self.ik_jnts[1], 1)
     cmds.setAttr('%s_translateX.postInfinity' % self.ik_jnts[2], 1)
     # stretch the result joints
     curve = '%s_%s_%s' % (self.side, 'upperArm', self.nc.curve)
     self.stretch_result_joints(curve, 'upperArm', self.upper_arm_jnts)
     curve = '%s_%s_%s' % (self.side, 'foreArm', self.nc.curve)
     self.stretch_result_joints(curve, 'foreArm', self.fore_arm_jnts)
开发者ID:jonntd,项目名称:Rigganator,代码行数:34,代码来源:arm.py

示例7: _setup_wire_deformer

    def _setup_wire_deformer(self, mesh, wire, wirebase, curve,
                             parent, complexity):
        """Setup the wire deformer. If complexity is 1 or higher call this
        function recursively to create a wire deformer on the nurbs surface.

        @param mesh(string): PolyMesh used to wire deform
        @param wire(string): Descriptive part of the name of the wire deformer
        @param wirebase(string): Descriptive part of the name of the base wire
        @param curve(string): Curve used for wireTool deformer
        @param parent(string): Parent node of the wire setup
        @param complexity(uint): complexity level value
        """
        w = wire
        wb = wirebase
        cmds.wire(mesh, w=curve, dds=[0, 10000], n=w, foc=False)
        cmds.rename(cmds.listConnections('%s.baseWire[0]' % w)[0], wb)
        if not cmds.listRelatives(curve, p=True) == [self.wire_grp]:
            cmds.parent(curve, wb, self.wire_grp)
        # end if
        wbs = cmds.listRelatives(wb, ad=True, type='shape')[0]
        cs = cmds.listRelatives(curve, ad=True, type='shape')[0]
        cmds.setAttr('%s.rotation' % w, 0)
        # connect to showHistory
        cmds.connectAttr('%s.showHistory' % self.mod_grp, '%s.ihi' % w)
        cmds.connectAttr('%s.showHistory' % self.mod_grp, '%s.ihi' % wb)
        cmds.connectAttr('%s.showHistory' % self.mod_grp, '%s.ihi' % wbs)
        cmds.connectAttr('%s.showHistory' % self.mod_grp, '%s.ihi' % cs)
        if complexity:
            cmds.duplicate(self.curve, n=self.nrbcurve)
            return self._setup_wire_deformer(self.surface, self.nrbwire,
                                             self.nrbwirebase, self.nrbcurve,
                                             self.parent, 0)
开发者ID:jonntd,项目名称:Public,代码行数:32,代码来源:volume_push_collider.py

示例8: bt_moveObjToCamera

def bt_moveObjToCamera():
    
    #Check for hotkey and make if possible
    bt_checkCtrFHotkey()

    activePanel = cmds.getPanel(wf=1)
    if "model" in activePanel:
        activeCamera = cmds.modelEditor(activePanel,q=1,camera=1)   
    else:
        cmds.error ('No active panel/camera to frame to')    
         
    selected = cmds.ls(sl=1)
    
    locator = cmds.spaceLocator()
    cmds.select(activeCamera,add=1)
    cmds.parent(r=1)
    cmds.move(0,0,-5,locator,r=1,os=1)
    location = cmds.xform(q=1,t=1,ws=1)
    
    for object in selected:
        cmds.move(location[0],location[1],location[2],object,ws=1,a=1)
        #cmds.move(location[0],location[1],location[2],'pCube1',ws=1,a=1)
        
    cmds.delete(locator)   
    cmds.select(selected,r=1)
开发者ID:cyrillef,项目名称:apps.exchange.packager,代码行数:25,代码来源:bt_moveObjToCamera.py

示例9: exportRig

 def exportRig(self):
     """ will export SH and Geo found in the geo folder """
     # rig and geo should not be referenced
     # find SH, delete constraints, parent to world
     # find geo folder parent to world
     # select SH and geo folder and export as fbx to fbx folder
     pymelLogger.debug( 'Starting rig export' )
     export = 0
     for rig in self.rootList:
         if cmds.objExists(rig): 
             # check if geo folder also exists
             if cmds.objExists(self.geo):
                 self._delConstraints(rig)  
                 cmds.parent(rig, w=1)
                 cmds.parent(self.geo, w=1)
                 cmds.select(rig,self.geo, r=1)
                 #print rig, self.geo
                 if self._fbxExport( 2 ):
                     cmds.confirmDialog(m='FBX Rig Exported', button='Ok')
                 pymelLogger.debug( 'Finished rig export' )
                 export = 1
                 break
             else: 
                 pymelLogger.error( 'No geo folder has been found' )
     if export == 0 : pymelLogger.error( 'No Rig Exported. Note: Referenced Rigs Will Not Export' )
开发者ID:Mauricio3000,项目名称:MSH_Maya,代码行数:25,代码来源:Export.py

示例10: create_module

	def create_module(self, moduleType):
		# new module dialog
		moduleName, ok = QtGui.QInputDialog().getText(self, 'Add ' + moduleType + ' Module', 'Enter module name:', QtGui.QLineEdit.Normal, moduleType)

		if ok and moduleName != "":

			# If module with name is exist
			if cmds.objExists(moduleName+":main"):
				QtGui.QMessageBox.information(self, "Warning", "This module is exist.")
			else:
				# add module to list
				item = QtGui.QListWidgetItem(moduleName)
				self.modules_listWidget.addItem(item)
				self.modules_listWidget.setCurrentItem(item)
				
				# import module  
				cmds.file("G:/Projects New/AnimaCord/pk_rig/%s/%s_rig.mb" %(moduleType,moduleType), r=True, type="mayaBinary", namespace=moduleName)
				cmds.file("G:/Projects New/AnimaCord/pk_rig/%s/%s_rig.mb" %(moduleType,moduleType), importReference=True )
				cmds.parent(moduleName+":main", characterRoot)
				
				# set module name
				cmds.setAttr(moduleName+":main.moduleName", moduleName, type="string")
				
				cmds.hide(moduleName+":controls")
				cmds.select(moduleName+":main_poser")
				
				self.update_modules_list()
开发者ID:PavelCrow,项目名称:pkRig,代码行数:27,代码来源:pk_rig_window.py

示例11: createTwistJoints

def createTwistJoints(joint, numTwistJoints, offsetAxis="x", prefix=""):
    """
	"""
    # Check joint
    if not mc.objExists(joint):
        raise Exception("Joint " + joint + " does not exist!")

        # Check prefix
    if not prefix:
        prefix = glTools.utils.stringUtils.stripSuffix(joint)

    # Get joint length
    jointEnd = mc.listRelatives(joint, c=True)[0]
    jointLen = mc.getAttr(jointEnd + ".t" + offsetAxis)
    jointOffset = jointLen / (numTwistJoints - 1)

    # Create twist joints
    twistJoints = []
    for i in range(numTwistJoints):

        alphaInd = glTools.utils.stringUtils.alphaIndex(i, upper=True)

        # Duplicate joint
        twistJoint = mc.duplicate(joint, po=True, n=prefix + "_twist" + alphaInd + "_jnt")[0]
        mc.parent(twistJoint, joint)

        # Position joint
        mc.setAttr(twistJoint + ".t" + offsetAxis, jointOffset * i)

        # Append twist joint list
        twistJoints.append(twistJoint)

        # Return result
    return twistJoints
开发者ID:RiggingDojoAdmin,项目名称:glTools,代码行数:34,代码来源:utils.py

示例12: __setup_final_meshes

    def __setup_final_meshes(self):
        #--- this method setups the final meshes
        if 'FINAL' in self.mesh:
            if cmds.objExists(self.mesh):
                self.final_mesh = self.mesh
            else:
                self.final_mesh = cmds.duplicate(self.mesh)
                cmds.parent(self.final_mesh, self.sf_final_meshes)
                final_name = cmds.rename(self.final_mesh,
                                         self.mesh)
                self.final_mesh = final_name
        else:
            if cmds.objExists(self.mesh + 'FINAL'):
                self.final_mesh = self.mesh + 'FINAL'
            else:
                self.final_mesh = cmds.duplicate(self.mesh)
                cmds.parent(self.final_mesh, self.sf_final_meshes)
                final_name = cmds.rename(self.final_mesh,
                                         self.mesh + 'FINAL')
                self.final_mesh = final_name

        if cmds.objExists(self.mesh + '_BSP'):
            #--- setup blendShape deformer
            self.final_bsp = self.mesh + '_BSP'
            cmds.setAttr(self.final_bsp + '.' + self.mesh, 1)
            cmds.setAttr(self.mesh + '.v', 0)
        else:
            if 'FINAL' in self.mesh:
                self.mesh = self.mesh.split('FINAL')[0]
            self.final_bsp = cmds.blendShape(self.mesh,
                                             self.final_mesh,
                                             name = self.mesh + '_BSP')[0]
            cmds.setAttr(self.final_bsp + '.' + self.mesh, 1)
            cmds.setAttr(self.mesh + '.v', 0)
开发者ID:jonntd,项目名称:Public,代码行数:34,代码来源:shotfinaling.py

示例13: ikRPsolver

    def ikRPsolver(self, 
                    startJoint = None, 
                    endEffector = 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
        ik = cmds.ikHandle(startJoint = startJoint, endEffector = endEffector, 
                           name = self.ik_name, solver = 'ikRPsolver')

        #--- rename the effector
        eff = cmds.rename(ik[-1], ik[0] + 'EFF')

        #--- store the ik_handle and effector in a list to return
        ik_handle = [ik[0], eff]

        #--- parent the ik_handle under the specified parent
        if parent:
            cmds.parent(ik_handle[0], parent)

        #--- hide the ik handle
        if hide:
            cmds.setAttr(ik_handle[0] + '.v', 0)

        cmds.select(clear = 1)
        return ik_handle
开发者ID:jonntd,项目名称:Public,代码行数:32,代码来源:ikhandle.py

示例14: createSplineCurveInfo

def createSplineCurveInfo( curve, number, **options ):
    
    crvShape = cmds.listRelatives( curve, s=1 )
    if not crvShape: return None
    crvShape = crvShape[0]
    
    splineNode = cmds.createNode( 'splineCurveInfo', n=curve+'_spline' )
    cmds.connectAttr( crvShape+'.local', splineNode+'.inputCurve' )
    
    if number <= 1:
        return None
    elif number > 1:
        eachRate = 1.0/(number-1)
        for i in range( number ):
            cmds.setAttr( splineNode+'.parameter[%d]' % i, eachRate*i+0.001 )
            
    for i in range( number-1 ):
        trNode = cmds.createNode( 'transform' )
        cmds.connectAttr( splineNode+'.output[%d].position' % i, trNode+'.t' )
        cmds.connectAttr( splineNode+'.output[%d].rotate' % i, trNode+'.r' )
        cmds.parent( trNode, curve )
        cmds.setAttr( trNode+'.dh', 1 )
        cmds.setAttr( trNode+'.dla', 1 )
    
    return splineNode
开发者ID:jonntd,项目名称:mayadev-1,代码行数:25,代码来源:sgRigSpline.py

示例15: _finger_hydraulics

    def _finger_hydraulics(self):
        """Connects the finger hydraulics."""
        for side in ['L', 'R']:
            for finger in ['pointer', 'middle', 'ring']:
                start_jnt = '%s_%sBase_result_%s' % (side, finger, self.nc.joint)
                end_jnt = '%s_%s1_result_%s' % (side, finger, self.nc.joint)

                if finger == 'ring':
                    finger = 'pinky'
                # END if

                start_hydraulic = '%s_%sHydraulicsStart_%s_%s' % (side, finger, self.nc.joint, self.nc.group)
                mid_hydraulic = '%s_%sHydraulicsMid_%s_%s' % (side, finger, self.nc.joint, self.nc.group)
                end_hydraulic = '%s_%sHydraulicsEnd_%s_%s' % (side, finger, self.nc.joint, self.nc.group)

                cmds.select(cl=True)
                start_offset = cmds.group(n='%s_%sBaseOffset_%s' % (side, finger, self.nc.group), empty=True)
                cmds.select(cl=True)
                end_offset = cmds.group(n='%s_%s2Offset_%s' % (side, finger, self.nc.group), empty=True)

                self.c.snap_a_to_b(start_offset, start_hydraulic)
                self.c.snap_a_to_b(end_offset, end_hydraulic)
                cmds.parent(start_offset, start_jnt)
                cmds.parent(end_offset, end_jnt)

                cmds.parent(start_hydraulic, start_offset)
                cmds.parent(end_hydraulic, end_offset)

                try:
                    cmds.parent(mid_hydraulic, '%s_hand_%s' % (side, self.nc.group))
                except Exception as err:
                    print err
开发者ID:jonntd,项目名称:Rigganator,代码行数:32,代码来源:dave.py


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