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


Python cmds.aliasAttr函数代码示例

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


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

示例1: doAlias

 def doAlias(self,arg):
     """ 
     Set the alias of an attribute
     
     Keyword arguments:
     arg(string) -- name you want to use as an alias
     """     
     assert type(arg) is str or unicode,"Must pass string argument into doAlias"                
     if arg:
         try:
             if arg != self.nameAlias:
                 if mc.aliasAttr(arg,self.nameCombined):
                     self.nameAlias = arg
             else:
                 guiFactory.report("'%s.%s' already has that alias!"%(self.obj.nameShort,self.attr,arg))
                 
         except:
             guiFactory.warning("'%s.%s' failed to set alias of '%s'!"%(self.obj.nameShort,self.attr,arg))
                 
     else:
         if self.nameAlias:
             self.attr = self.nameLong                
             mc.aliasAttr(self.nameCombined,remove=True)
             self.nameAlias = False
             self.updateData()
开发者ID:GuidoPollini,项目名称:MuTools,代码行数:25,代码来源:AttrFactory.py

示例2: addPose

def addPose(tangentBlend, baseGeo='', offsetGeo='', poseName=''):
    """
    @param tangentBlend:
    @param baseGeo:
    @param offsetGeo:
    @param poseName:
    """
    # Define suffix tags
    tangentBlend_baseTag = '_poseBase'
    tangentBlend_offsetTag = '_poseOffset'

    # Get connected geometry
    geo = findAffectedGeometry(tangentBlend)

    # Check pose geometry
    if not baseGeo: baseGeo = duplicateGeo(geo, geo + tangentBlend_baseTag)
    if not offsetGeo: baseGeo = duplicateGeo(geo, geo + tangentBlend_offsetTag)

    # Connect to deformer
    poseIndex = connectPose(baseGeo, offsetGeo, tangentBlend)

    # Alias pose name and set keyable
    if poseName:
        cmds.aliasAttr(poseName, tangentBlend + '.pose[' + str(poseIndex) + '].poseWeight')
        cmds.setAttr(tangentBlend + '.pose[' + str(poseIndex) + '].poseWeight', cb=True)
        cmds.setAttr(tangentBlend + '.pose[' + str(poseIndex) + '].poseWeight', k=True)

    return [baseGeo, offsetGeo]
开发者ID:bennymuller,项目名称:glTools,代码行数:28,代码来源:tangentBlend.py

示例3: add

	def add(self,objectList):
		'''
		Adds the channel state attr to all specified objects
		@param objectList: List of objects to add flags to
		@type objectList: list
		'''
		# Add Channel State Attrs
		for obj in objectList:
			
			# Check obj
			if not mc.objExists(obj):
				raise Exception('Object "'+obj+'" does not exist!')
			if not glTools.utils.transform.isTransform(obj):
				raise Exception('Object "'+obj+'" is not a valid transform!')
			if mc.objExists(obj+'.channelState'):
				print ('Object "'+obj+'" already has a "channelState" attribute! Skipping...')
			
			# Add channelState attr
			#mc.addAttr(obj,ln='channelState',at='enum',en=':Keyable:NonKeyable:Locked:',m=1,dv=-1)
			mc.addAttr(obj,ln='channelState',at='enum',en=':Keyable:NonKeyable:Locked:',m=1)
			
			# Set channelState flag values
			for i in range(len(self.channel)):
				if mc.getAttr(obj+'.'+self.channel[i],l=1):
					# Set Locked State
					mc.setAttr(obj+'.channelState['+str(i)+']',2)
				elif not mc.getAttr(obj+'.'+self.channel[i],k=1):
					# Set NonKeyable State
					mc.setAttr(obj+'.channelState['+str(i)+']',1)
				else:
					# Set Keyable State
					mc.setAttr(obj+'.channelState['+str(i)+']',0)
				# Alias Attribute
				mc.aliasAttr(self.channel[i]+'_state',obj+'.channelState['+str(i)+']')
开发者ID:auqeyjf,项目名称:glTools,代码行数:34,代码来源:channelState.py

示例4: _disconnectAndRemoveAttr

def _disconnectAndRemoveAttr(attr, remove=False):
	"""Disconnects inputs and outputs from the given attribute."""
	
	sel = cmds.ls(sl=True)
	cmds.select(cl=True)
	
	# unlock if needed
	cmds.setAttr(attr, l=False)
	
	# if any connection, disconnect
	srcAttrs = cmds.listConnections(attr, d=False, p=True) or []
	destAttrs = cmds.listConnections(attr, s=False, p=True) or []
	for srcAttr in srcAttrs:
		cmds.disconnectAttr(srcAttr, attr)
	
	for destAttr in destAttrs:
		cmds.disconnectAttr(attr, destAttr)
	
	# remove element
	if remove:
		cmds.removeMultiInstance(attr)
		
		# remove alias
		if cmds.aliasAttr(attr, q=True):
			cmds.aliasAttr(attr, rm=True)
	
	cmds.select(sel or None)
开发者ID:Bumpybox,项目名称:Tapp,代码行数:27,代码来源:ZvRadialBlendShape.py

示例5: setDefaultAttrState

def setDefaultAttrState(objList,attrList,valueList=[]):
	'''
	Set default attribute state values for a specified list of object attributes.
	@param objList: List of objects to store default attribute state values for.
	@type objList: list
	@param attrList: List of attributes to store default attribute state values for.
	@type attrList: list
	@param valueList: List of attributes values to assign to the default attribute states. If empty, use current object attribute values.
	@type valueList: list
	'''
	# Check Object List
	if not objList: return
	if not attrList: return
	if len(attrList) != len(valueList):
		print ('Attribute and value list mis-match! Recording existing attribute values.')
		valueList = []
	
	# Define defaultAttrState attribute name
	defAttr = 'defaultAttrState'
	aliasSuffix = 'defaultState'
	
	# For each object in list
	for obj in objList:
		
		# Check Object
		if not mc.objExists(obj):
			raise Exception('Object "'+obj+'" does not exist!')
		if not mc.attributeQuery(defAttr,n=obj,ex=True):
			addDefaultAttrState([obj])
		
		# For each attribute in list
		for i in range(len(attrList)):
			
			# Get current attribute
			attr = attrList[i]
			attrAlias = attr+'_'+aliasSuffix
			
			# Check attribute
			if not mc.attributeQuery(attr,n=obj,ex=True):
				raise Exception('Object "'+obj+'" has no attribute "'+attr+'"!')
			
			# Get attribute value
			if valueList: value = valueList[i]
			else: value = mc.getAttr(obj+'.'+attr)
			
			# Add default attribute state
			if not mc.attributeQuery(attrAlias,n=obj,ex=True):
				try: index = mc.getAttr(obj+'.'+defAttr,s=True)
				except: print('Error getting multi length from "'+obj+'.'+defAttr+'"')
				mc.setAttr(obj+'.'+defAttr+'['+str(index)+']',0)
				try: mc.aliasAttr(attrAlias,obj+'.'+defAttr+'['+str(index)+']')
				except: print('Error setting attribute alias ("'+attrAlias+'") for node attr "'+obj+'.'+defAttr+'['+str(index)+']"')
			
			# Set default attribute state
			try: mc.setAttr(obj+'.'+attrAlias,value)
			except: print('Unable to set default attr state ("'+attrAlias+'") for object "'+obj+'" to value ('+str(value)+')!')
开发者ID:auqeyjf,项目名称:glTools,代码行数:56,代码来源:defaultAttrState.py

示例6: init_module_trans

	def init_module_trans(self,root_pos):

		ctrl_grp_file = os.environ["mlrig_tool"]+"/controlobjects/blueprint/controlGroup_control.ma"
		cmds.file(ctrl_grp_file, i=True)

		self.module_trans = cmds.rename("controlGroup_control", self.module_namespace+":module_transform")

		cmds.xform(self.module_trans, worldSpace=True, absolute=True, translation=root_pos)

		# mirroring method
		if self.mirrored:

			duplicate_transform = cmds.duplicate(self.original_module+":module_transform", parentOnly=True, name="TEMP_TRANSFORM")[0]
			empty_group = cmds.group(empty=True)
			cmds.parent(duplicate_transform, empty_group, absolute=True)

			scale_attr = ".scaleX"

			if self.mirror_plane == "XZ":

				scale_attr = ".scaleY"

			elif self.mirror_plane == "XY":

				scale_attr = ".scaleZ"

			cmds.setAttr(empty_group+scale_attr, -1)

			parent_constraint = cmds.parentConstraint(duplicate_transform, self.module_trans, maintainOffset=False)
			
			cmds.delete(parent_constraint)
			cmds.delete(empty_group)

			temp_locator = cmds.spaceLocator()[0]
			scale_constraint = cmds.scaleConstraint(self.original_module+":module_transform", temp_locator, maintainOffset=False)[0]

			scale = cmds.getAttr(temp_locator+".scaleX")
			cmds.delete([temp_locator, scale_constraint])

			cmds.xform(self.module_trans, objectSpace=True, scale=[scale, scale, scale])

		utils.add_node_to_container(self.container_name, self.module_trans, ihb=True)

		# Setup global scaling 

		cmds.connectAttr(self.module_trans+".scaleY", self.module_trans+".scaleX")
		cmds.connectAttr(self.module_trans+".scaleY", self.module_trans+".scaleZ")

		cmds.aliasAttr("globalScale", self.module_trans+".scaleY")

		cmds.container(self.container_name, edit=True, publishAndBind=[self.module_trans+".translate", "moduleTransform_T"])
		cmds.container(self.container_name, edit=True, publishAndBind=[self.module_trans+".rotate", "moduleTransform_R"])
		cmds.container(self.container_name, edit=True, publishAndBind=[self.module_trans+".globalScale", "moduleTransform_globalScale"])
开发者ID:firstPeterParker,项目名称:mlRig,代码行数:53,代码来源:blueprint.py

示例7: createTemporaryGroupRepresentation

	def createTemporaryGroupRepresentation(self):
		controlGrpFile = os.environ['RIGGING_TOOL_ROOT'] + '/ControlObjects/Blueprint/controlGroup_control.ma'
		cmds.file(controlGrpFile, i=True)
		
		self.tempGroupTransform = cmds.rename('controlGroup_control', 'Group_tempGroupTransform__')
		
		cmds.connectAttr((self.tempGroupTransform + '.scaleY'),(self.tempGroupTransform + '.scaleX'))
		cmds.connectAttr((self.tempGroupTransform + '.scaleY'),(self.tempGroupTransform + '.scaleZ'))
		
		for attr in ['scaleX', 'scaleZ','visibility']:
			cmds.setAttr((self.tempGroupTransform + '.' + attr), l=True, k=False)
			
		cmds.aliasAttr('globalScale', (self.tempGroupTransform + '.scaleY'))
开发者ID:pouyaz123,项目名称:Python-character-pipeline,代码行数:13,代码来源:groupSelected.py

示例8: createTemporaryGroupRepresentation

 def createTemporaryGroupRepresentation(self):
     #063
     # Import a new transform
     controlGrpFile = os.environ["GEPPETTO"] + "/ControlObjects/Blueprint/controlGroup_control.ma"
     cmds.file(controlGrpFile, i=True)
     # rename the transform
     self.tempGroupTransform = cmds.rename("controlGroup_control", "Group__tempGroupTransform__")
     # Hook all scale attributes to scaleY
     cmds.connectAttr(self.tempGroupTransform+".scaleY", self.tempGroupTransform+".scaleX")
     cmds.connectAttr(self.tempGroupTransform+".scaleY", self.tempGroupTransform+".scaleZ")
     # Lock unused attributes
     for attr in ["scaleX", "scaleZ", "visibility"]:
         cmds.setAttr(self.tempGroupTransform+"."+attr, l=True, k=False)
         
     cmds.aliasAttr("globalScale", self.tempGroupTransform+".scaleY")
开发者ID:griffinanimator,项目名称:MPR,代码行数:15,代码来源:groupSelected.py

示例9: rename

	def rename( self, oldName, newName ):
		'''will rename a blend shape target - if the target doesn't exist, the method does nothing...'''
		names = self.targets
		aliasList = cmd.aliasAttr(self.name,query=True)
		if oldName in names:
			idx = aliasList.index(oldName)
			aliasList[idx] = newName
			for n in range(1,len(aliasList),2): aliasList[n] = self.name +'.'+ aliasList[n]

			#now remove all the alias'
			for name in names: cmd.aliasAttr(self.name +'.'+ name,remove=True)

			#finally rebuild the alias'
			cmdStr = 'aliasAttr ' + ' '.join(aliasList) +';'
			maya.mel.eval(cmdStr)
开发者ID:GuidoPollini,项目名称:MuTools,代码行数:15,代码来源:blendShapeTools.py

示例10: create_temp_grp_representation

	def create_temp_grp_representation(self):

		control_group_file = os.environ["mlrig_tool"]+"/controlobjects/blueprint/controlGroup_control.ma"
		cmds.file(control_group_file, i=True)

		self.temp_group_transform = cmds.rename("controlGroup_control", "Group__tempGroupTransform__")

		cmds.connectAttr(self.temp_group_transform+".scaleY", self.temp_group_transform+".scaleX")
		cmds.connectAttr(self.temp_group_transform+".scaleY", self.temp_group_transform+".scaleZ")

		for attr in ["scaleX", "scaleZ", "visibility"]:

			cmds.setAttr(self.temp_group_transform+"."+attr, keyable=False, lock=True)

		cmds.aliasAttr("globalScale", self.temp_group_transform+".scaleY")
开发者ID:firstPeterParker,项目名称:mlRig,代码行数:15,代码来源:group_selected.py

示例11: loadModuleControl

    def loadModuleControl(self, rootJoint):

        path = environ.ControlObjectsPath + "module_control.ma"
        cmds.file(path, i = True, ignoreVersion = True,  renameAll=True, mergeNamespacesOnClash=True, namespace=':', options='v=0;')

        self.moduleControl = cmds.rename("module_control", self.moduleName + ":module_control")

        cmds.xform(self.moduleControl, ws = True, translation = cmds.xform(rootJoint, q = True, ws = True, a = True, translation = True) )

        cmds.connectAttr(self.moduleControl + '.scaleY', self.moduleControl + '.scaleX')
        cmds.connectAttr(self.moduleControl + '.scaleY', self.moduleControl + '.scaleZ')

        cmds.aliasAttr('globalScale', self.moduleControl + '.scaleY')

        return
开发者ID:jeffhong21,项目名称:scripts,代码行数:15,代码来源:blueprint.py

示例12: getTargetIndex

def getTargetIndex(blendShape, target):
    """
    Get the target index of the specified blendShape and target name
    @param blendShape: Name of blendShape to get target index for
    @type blendShape: str
    @param target: BlendShape target to get the index for
    @type target: str
    """
    # Check blendShape
    if not isBlendShape(blendShape):
        raise Exception('Object "' + blendShape + '" is not a valid blendShape node!')

    # Check target
    if not cmds.objExists(blendShape + '.' + target):
        raise Exception('Blendshape "' + blendShape + '" has no target "' + target + '"!')

    # Get attribute alias
    aliasList = cmds.aliasAttr(blendShape, q=True)
    aliasIndex = aliasList.index(target)
    aliasAttr = aliasList[aliasIndex + 1]

    # Get index
    targetIndex = int(aliasAttr.split('[')[-1].split(']')[0])

    # Return result
    return targetIndex
开发者ID:bennymuller,项目名称:glTools,代码行数:26,代码来源:blendShape.py

示例13: connectInbetween

def connectInbetween(
						blendShapeObject = '' ,
						blendShapeNode = '' ,
						inbetweenBlendShape = '' ,
						targetBlendShapeName = '' ,
						weightValue = ''
					) :
	
	# Add inbetween blend shape.

	aliasAttrList = mc.aliasAttr( blendShapeNode , q=True )

	for each in aliasAttrList :

		if each == targetBlendShapeName :

			idx = aliasAttrList.index( each )
			wStr = str( aliasAttrList[ idx+1 ] )
			wIdx = re.findall( r'\d+' , wStr )[0]

			cmd = 'blendShape -e  -ib -t %s %s %s %s %s;' % (
																blendShapeObject ,
																wIdx ,
																inbetweenBlendShape ,
																weightValue ,
																blendShapeNode
															)
			
			mm.eval( cmd )
开发者ID:myCodeTD,项目名称:pkmel,代码行数:29,代码来源:blendShapeTools.py

示例14: _buildPoseDict

    def _buildPoseDict(self, nodes):
        """
        Build the internal poseDict up from the given nodes. This is the
        core of the Pose System
        """
        if self.metaPose:
            getMetaDict = self.metaRig.getNodeConnectionMetaDataMap  # optimisation

        for i, node in enumerate(nodes):
            key = r9Core.nodeNameStrip(node)
            self.poseDict[key] = {}
            self.poseDict[key]["ID"] = i  # selection order index
            self.poseDict[key]["longName"] = node  # longNode name

            if self.metaPose:
                self.poseDict[key]["metaData"] = getMetaDict(node)  # metaSystem the node is wired too

            channels = r9Anim.getSettableChannels(node, incStatics=True)
            if channels:
                self.poseDict[key]["attrs"] = {}
                for attr in channels:
                    if attr in self.skipAttrs:
                        log.debug("Skipping attr as requested : %s" % attr)
                        continue
                    try:
                        if (
                            cmds.getAttr("%s.%s" % (node, attr), type=True) == "TdataCompound"
                        ):  # blendShape weights support
                            attrs = cmds.aliasAttr(node, q=True)[::2]  # extract the target channels from the multi
                            for attr in attrs:
                                self.poseDict[key]["attrs"][attr] = cmds.getAttr("%s.%s" % (node, attr))
                        else:
                            self.poseDict[key]["attrs"][attr] = cmds.getAttr("%s.%s" % (node, attr))
                    except:
                        log.debug("%s : attr is invalid in this instance" % attr)
开发者ID:vitattoo,项目名称:Red9_StudioPack,代码行数:35,代码来源:Red9_PoseSaver.py

示例15: getObjAttrNames

def getObjAttrNames( obj, attrNamesToSkip=() ):

	#grab attributes
	objAttrs = cmd.listAttr( obj, keyable=True, visible=True, scalar=True ) or []

	#also grab alias' - its possible to pass in an alias name, so we need to test against them as well
	aliass = cmd.aliasAttr( obj, q=True ) or []

	#because the aliasAttr cmd returns a list with the alias, attr pairs in a flat list, we need to iterate over the list, skipping every second entry
	itAliass = iter( aliass )
	for attr in itAliass:
		objAttrs.append( attr )
		itAliass.next()

	filteredAttrs = []
	for attr in objAttrs:
		skipAttr = False
		for skipName in attrNamesToSkip:
			if attr == skipName:
				skipAttr = True
			elif attr.startswith( skipName +'[' ) or attr.startswith( skipName +'.' ):
				skipAttr = True

		if skipAttr:
			continue

		filteredAttrs.append( attr )

	return filteredAttrs
开发者ID:BGCX261,项目名称:zootoolbox-git,代码行数:29,代码来源:animLib.py


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