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


Python cmds.setAttr函数代码示例

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


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

示例1: create_line_from_2_obj

    def create_line_from_2_obj(self, obja, objb, crv_name='_curve_CRV'):
        '''
        Desc:
        Make a line between 2 objects

        Parameter:
        crv_name = name of curve
        pta = first object
        ptb = second object

        Return: Curve name
        '''

        # Define generic curve
        curve=cmds.curve(d=1, p=[(0,0,0),(0,0,0)], k=[0,1], n=crv_name)
        cmds.setAttr(curve+'.overrideEnabled',1)
        cmds.setAttr(curve+'.overrideColor', 13)

        # Making connection in worldSpace using decomposeMatrix
        dMa=cmds.createNode('decomposeMatrix', n='_DMAT')
        dMb=cmds.createNode('decomposeMatrix', n='_DMAT')

        # Connect control worldMatrix to decomposeMatrix.inputMatrix
        KstMaya.node_op(obja+'.worldMatrix','>>', dMa+'.inputMatrix')
        KstMaya.node_op(dMa+'.outputTranslate','>>',curve+'.controlPoints[0]')
        KstMaya.node_op(objb+'.worldMatrix','>>', dMb+'.inputMatrix')
        KstMaya.node_op(dMb+'.outputTranslate','>>',curve+'.controlPoints[1]')
        return curve
开发者ID:Leopardob,项目名称:Kistie,代码行数:28,代码来源:KstRig.py

示例2: spaceSwitchToken

 def spaceSwitchToken(self, obj, args):
     
     objects, attr, switchTo     = args       
     enumTokens                  = animMod.getTokens(obj, attr)
     value                       = 0
     switchToNum                 = None
     
     for loopToken in enumTokens:
         splitValue = loopToken.split("=")
         
         if splitValue:
             if len(splitValue) > 1:
                 loopToken = splitValue[0]
                 value     = eval(splitValue[1])
         
         
         if switchTo == loopToken:
             switchToNum = value
             break
         
         value += 1
         
         
     if switchToNum != None:  
         cmds.setAttr("%s.%s"%(obj, attr), switchToNum)     
开发者ID:Italic-,项目名称:maya-prefs,代码行数:25,代码来源:spaceSwitch.py

示例3: removeFloatVariable

 def removeFloatVariable(self, nodeAttr, varslayout, index):
    # Remove variable
    children = cmds.columnLayout(varslayout, query=1, childArray=1)
    
    if len(children) <= index:
       return
    
    baseNameAttr = nodeAttr
    baseValueAttr = nodeAttr.replace("fparam_name", "fparam_value");
    
    for i in xrange(index+1, len(children)):
       rembtn, namefld, _, valfld = cmds.formLayout(children[i], query=1, childArray=1)
       
       indexStr = "[%d]" % (i - 1)
       nextIndexStr = "[%d]" % i
       
       nameAttr = baseNameAttr + indexStr
       valueAttr = baseValueAttr + indexStr
       
       cmds.setAttr(nameAttr, cmds.getAttr(baseNameAttr + nextIndexStr), type="string")
       cmds.setAttr(valueAttr, cmds.getAttr(baseValueAttr + nextIndexStr));
       
       self.setupVariableNameCallback(nameAttr, namefld)
       self.setupFloatVariableValueCallback(valueAttr, valfld)
       cmds.button(rembtn, edit=1, command=lambda *args: self.removeFloatVariable(nodeAttr, varslayout, i-1))
    
    cmds.deleteUI(children[index])
    
    cmds.removeMultiInstance("%s[%d]" % (baseNameAttr, len(children)-1), b=True)
    cmds.removeMultiInstance("%s[%d]" % (baseValueAttr, len(children)-1), b=True)
开发者ID:mousekoz,项目名称:SeExprArnold,代码行数:30,代码来源:aiSeexprTemplate.py

示例4: set_color

    def set_color(self, position):
        """Change display color of shapes"""

        color = common.get_color_index(position)
        for shape in self.nodes:
            cmds.setAttr("%s.overrideEnabled" % shape, 1)
            cmds.setAttr("%s.overrideColor" % shape, color)
开发者ID:eddiehoyle,项目名称:link,代码行数:7,代码来源:shape.py

示例5: createLocators

    def createLocators(self):
        #create list of loc names (self.name)
        for i in range(len(self.jointList)):
            self.locList.append("%s_%s_Loc"%(self.jointList[i],self.limbName))

        #check that these don't exist already
        if (cmds.objExists(self.locList[0])):
            cmds.error("these limb locators exists already!")
        else:

            #fill dictionary - assign values from list
            self.locPos = {}
            for j in range(len(self.locList)):
                self.locPos[self.locList[j]] = self.locPosValues[j]

            #create the locs
            for key in self.locPos.keys():
                thisLoc = cmds.spaceLocator(n=key)
                cmds.move(self.locPos[key][0], self.locPos[key][1], self.locPos[key][2], thisLoc)

            #parent them together (from list of loc names)
            for k in range((len(self.locList)-1),0,-1):
                cmds.parent(self.locList[k], self.locList[k-1])

######### make this true only for the arms. . . or figure out how to extract which rot this should be
            #rotate second joint to just get a preferred angle
            cmds.setAttr("%s.ry"%self.locList[1], -5)
开发者ID:zethwillie,项目名称:python_rigger,代码行数:27,代码来源:baseLimb.py

示例6: connectBind

 def connectBind(self):
     #Create opposite node to blend
     blendOpposite = rc.create1MinusNode(
         "%s.%s" %(self.m_blendControl, self.m_blendAttr),
         "%s_IKFKBlendOpp_CTRL" %(self.m_name)
         )
     for i in range(len(self.m_bindJoints)):
         const1 = cmds.parentConstraint(
             self.m_ikJoints[i],
             self.m_bindJoints[i],
             st = ["x", "y", "z"]
             )[0]
         const2 = cmds.parentConstraint(
             self.m_fkJoints[i],
             self.m_bindJoints[i],
             st = ["x", "y", "z"]
             )[0]
         cmds.connectAttr(
             blendOpposite,
             "%s.blendParent2" %(self.m_bindJoints[i])
             )
         # Change to quarternion
         pairBlend = cmds.listConnections(
             "%s.constraintRotateX" %(const1),
             d=1
             )[0]
         cmds.setAttr("%s.rotInterpolation" %(pairBlend), 1)
开发者ID:jaredauty,项目名称:Rigging,代码行数:27,代码来源:FootRig.py

示例7: stampCompiled

 def stampCompiled(self, audioNodes):
     '''
     Used by the compiler - stamp the audioNodes from which this audio
     track was compiled from
     '''
     cmds.addAttr(self.audioNode, longName='compiledAudio', dt='string')
     cmds.setAttr('%s.compiledAudio' % self.audioNode, ','.join(audioNodes), type="string")
开发者ID:jeanim,项目名称:Red9_StudioPack,代码行数:7,代码来源:Red9_Audio.py

示例8: _mirror_setFollowValues

 def _mirror_setFollowValues(self):
     for target in self.__followTargets:
         if target.find( 'Collar' ) != -1:
             otherTarget = target.replace( 'Collar_L', 'Arm_L_PoleV' ).replace( 'Collar_R', 'Arm_R_PoleV' )
             mtxList = cmds.getAttr( otherTarget+'.wm' )
         elif target.find( 'Leg' ) != -1:
             poleVTarget = target.replace( 'Switch_CTL', 'PoleV_CTL' )
             poleVMtxList = cmds.getAttr( poleVTarget+'.wm' )
             mtxList = cmds.getAttr( target.replace( 'Switch', 'IK' )+'.wm' )
         else:
             mtxList = cmds.getAttr( target.replace( 'Switch', 'IK' )+'.wm' )
         
         index = self.__followTargets.index( target )
         udAttrs = cmds.listAttr( target, ud=1 )
         
         for attr in udAttrs:
             if attr.find( 'Follow' ) != -1:
                 cmds.setAttr( target+'.'+attr, self.__followValues[index].pop(0) )
                 
         if target.find( 'Switch' ) != -1: target = target.replace( 'Switch', 'IK' )
         elif target.find( 'Collar' ) != -1:
             target = target.replace( 'Collar_L', 'Arm_L_PoleV' ).replace( 'Collar_R', 'Arm_R_PoleV' )
         
         cmds.xform( target, ws=1, matrix = mtxList )
         if cmds.nodeType( target ) == 'joint':
             rigbase.setRotate_keepJointOrient( mtxList, target )
             
         if target.find( 'Leg' ) != -1:
             cmds.xform( poleVTarget, ws=1, matrix = poleVMtxList )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:29,代码来源:allCtlsCmd.py

示例9: goToObject

    def goToObject(self, first, second, *args ):
        
        if cmds.nodeType( first ) == 'joint':
            
            jo = cmds.getAttr( first+'.jo' )[0]
            mpxTransform = mpx.MPxTransformationMatrix()
            rotVector = om.MVector( math.radians( jo[0] ), math.radians( jo[1] ), math.radians( jo[2] ) ) 
            mpxTransform.rotateTo( om.MEulerRotation( rotVector ) )
            joMtx = mpxTransform.asMatrix()
            
            fMtx = om.MMatrix()
            fPMtx = om.MMatrix()
            fMtxList = cmds.getAttr( first+'.wm' )
            fPMtxList = cmds.getAttr( first+'.pm' )
            sMtx = om.MMatrix()
            sMtxList = cmds.getAttr( second+'.wm' )
            
            om.MScriptUtil.createMatrixFromList( fMtxList, fMtx )
            om.MScriptUtil.createMatrixFromList( fPMtxList, fPMtx )
            om.MScriptUtil.createMatrixFromList( sMtxList, sMtx )
            
            sMtxPose = [ sMtx(3,0), sMtx(3,1), sMtx(3,2) ]
            
            rMtx = sMtx*(joMtx*fPMtx).inverse()
            rTransform = mpx.MPxTransformationMatrix( rMtx )
            rVector = rTransform.eulerRotation().asVector()
            
            rot = [ math.degrees( rVector.x ), math.degrees( rVector.y ), math.degrees( rVector.z ) ]

            cmds.setAttr( first+'.r', *rot )
            cmds.move( sMtxPose[0], sMtxPose[1], sMtxPose[2], first, ws=1 )

        else:
            rigbase.goToSamePosition( first, second )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:34,代码来源:allCtlsCmd.py

示例10: setupScene

def setupScene():
	'''
	Setup some scene attributes we want to be common to all Spinifex car scenes
	TODO:
	make width over height as float
	'''
		
	# Check if we haven't done this before
	if cmds.objExists('vraySettings.setupSceneHasBeenRun'):
		# Check that everything is setup correctly before continuing.
		dialogMessage = 'setupScene has already been run. Do you wish to continue? Some of your render settings will be reset.'
		result = cmds.confirmDialog( title='spckSetupScene', message=dialogMessage, button=['YES','NO'], defaultButton='NO', cancelButton='NO', dismissString='NO' )
		if result == 'NO' :
			print("Aborted. We\'ve done this before...\n")
			return
	else:
		# Check that everything is setup correctly before continuing.
		dialogMessage = 'Have you set up your workspace.mel?'
		result = cmds.confirmDialog( title='spckSetupScene', message=dialogMessage, button=['YES','NO'], defaultButton='YES', cancelButton='NO', dismissString='NO' )
		if result == 'NO' :
			print('Go setup your workspace and run again.\n')
			return
		
	# Units for working in metric and 30fps
	cmds.currentUnit (linear='cm')
	cmds.currentUnit (angle='deg')
	cmds.currentUnit (time='ntsc')

	# Load VRAY if not active
	cmds.loadPlugin ('vrayformaya', quiet=True)
	cmds.pluginInfo ('vrayformaya', edit=True, autoload=True)
	cmds.setAttr  ('defaultRenderGlobals.ren', 'vray', type='string')

	cmds.evalDeferred ( 'createBaseRenderSettings()' , lowestPriority=True )	
	print('Success.\n')
开发者ID:mybikeislost,项目名称:studio_pipeline,代码行数:35,代码来源:setupScene.py

示例11: _mirror_setFollowDefault

 def _mirror_setFollowDefault(self):
     for target in self.__followTargets:
         if target.find( 'Collar' ) != -1:
             otherTarget = target.replace( 'Collar_L', 'Arm_L_PoleV' ).replace( 'Collar_R', 'Arm_R_PoleV' )
             mtxList = cmds.getAttr( otherTarget+'.wm' )
         elif target.find( 'Leg' ) != -1:
             poleVTarget = target.replace( 'Switch_CTL', 'PoleV_CTL' )
             poleVMtxList = cmds.getAttr( poleVTarget+'.wm' )
             mtxList = cmds.getAttr( target.replace( 'Switch', 'IK' ) +'.wm' )
         else:
             mtxList = cmds.getAttr( target.replace( 'Switch', 'IK' ) +'.wm' )
         
         udAttrs = cmds.listAttr( target, ud=1 )
         for attr in udAttrs:
             if attr.find( 'Follow' ) != -1:
                 case1 = target.find( 'Arm' ) != -1 and attr == 'collarFollow'
                 case2 = target.find( 'Leg' ) != -1 and attr == 'hipFollow'
                 case3 = attr == 'neckFollow'
                 if case1 or case2 or case3:
                     cmds.setAttr( target+'.'+attr, 10 )
                 else:
                     cmds.setAttr( target+'.'+attr, 0 )
                     
         if target.find( 'Switch' ) != -1: target = target.replace( 'Switch', 'IK' )
         elif target.find( 'Collar' ) != -1:
             target = target.replace( 'Collar_L', 'Arm_L_PoleV' ).replace( 'Collar_R', 'Arm_R_PoleV' )
         cmds.xform( target, ws=1, matrix = mtxList )
         if cmds.nodeType( target ) == 'joint':
             rigbase.setRotate_keepJointOrient(mtxList, target)
         
         if target.find( 'Leg' ) != -1:
             cmds.xform( poleVTarget, ws=1, matrix = poleVMtxList )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:32,代码来源:allCtlsCmd.py

示例12: main

def main(selectedChannels=True, transformsOnly=False):
    '''
    Resets selected channels in the channel box to default, or if nothing's
    selected, resets all keyable channels to default.
    '''
    gChannelBoxName = mm.eval('$temp=$gChannelBoxName')
    
    sel = mc.ls(sl=True)
    if not sel:
        return
    
    chans = None
    if selectedChannels:
        chans = mc.channelBox(gChannelBoxName, query=True, sma=True)
    
    testList = ['translateX','translateY','translateZ','rotateX','rotateY','rotateZ','scaleX','scaleY','scaleZ',
                'tx','ty','yz','rx','ry','rz','sx','sy','sz']
    for obj in sel:
        attrs = chans
        if not chans:
            attrs = mc.listAttr(obj, keyable=True, unlocked=True)
        if transformsOnly:
            attrs = [x for x in attrs if x in testList]
        if attrs:
            for attr in attrs:
                try:
                    default = mc.attributeQuery(attr, listDefault=True, node=obj)[0]
                    mc.setAttr(obj+'.'+attr, default)
                except StandardError:
                    pass
                
    utl.deselectChannels()
开发者ID:GuidoPollini,项目名称:MuTools,代码行数:32,代码来源:ml_resetChannels.py

示例13: followAttrVis

 def followAttrVis(self, ctlNameList, attrName, onOff, *args ):
     if onOff == True:
         for ctlName in ctlNameList:
             cmds.setAttr( ctlName+'.'+attrName, e=1, k=1 )
     else:
         for ctlName in ctlNameList:
             cmds.setAttr( ctlName+'.'+attrName, e=1, k=0 )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:7,代码来源:ui.py

示例14: modifiy_joint_chain_axis

    def modifiy_joint_chain_axis(joint_chain, orient_chain='xyz', up_axis_chain='yup'):
        '''
        Desc:
        Modify specified joint chain orientation

        Parameter:
        joint_chain = chain to affect
        orient_chain = axis to orient
        up_axis_chain = chain up axis

        Return:
        None
        '''
        for i in range(0, len(joint_chain)):
            KstOut.debug(KstRig._debug, 'Reorient current joint:' )
            KstOut.debug(KstRig._debug, 'joint: %s' % joint_chain[i])
            try:
                cmds.joint(joint_chain[i], e=True, zso=True, oj=orient_chain, sao=up_axis_chain, ch=True)
            except:
                print('Error on reorient, check the rotations')

            # If it's the last joint reset rotation axis
            if i == len(joint_chain)-1:
                rot_axis = ['X','Y','Z']
                for axis in rot_axis:
                    cmds.setAttr(joint_chain[i]+'.jointOrient'+axis, 0)
开发者ID:Leopardob,项目名称:Kistie,代码行数:26,代码来源:KstRig.py

示例15: addVrayObjectIds

def addVrayObjectIds(shapes=None):
    """ Add a vray_objectID attribute to selected meshes

    :param shapes: Shapes to apply the attribute to. If shapes is None it will get
                   the shapes related to the current selection.
    """
    if shapes is None:
        shapes = mc.ls(sl=1, s=1, dag=1, lf=1, o=1, long=True)

    if shapes:
        # Can only add objectIds to mesh, nurbsSurface so lets filter it
        shapes = mc.ls(shapes, type=("mesh", "nurbsSurface"))

    if shapes:
        result = mc.promptDialog(
            title="Object ID value",
            message="Object ID:",
            button=["OK", "Cancel"],
            defaultButton="OK",
            cancelButton="Cancel",
            dismissString="Cancel",
        )

        if result == "OK":
            value = int(mc.promptDialog(query=True, text=True))

            for shape in shapes:
                mc.vray("addAttributesFromGroup", shape, "vray_objectID", 1)
                mc.setAttr("{0}.{1}".format(shape, "vrayObjectID"), value)
开发者ID:BigRoy,项目名称:mayaVrayCommandDocs,代码行数:29,代码来源:addVrayObjectIds.py


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