• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python cmds.addAttr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _create_functionality

    def _create_functionality(self):
        ctl = self.get_control(0)
        attrs = ['heel', 'ball', 'tip', 'bankIn', 'bankOut']
        for attr in attrs:
            cmds.addAttr(ctl.ctl, ln=attr, at="double", min=-10, max=10)
            cmds.setAttr("%s.%s" % (ctl.ctl, attr), cb=True)
            cmds.setAttr("%s.%s" % (ctl.ctl, attr), k=True)

        # Standard connections
        self.range_detail = {}
        for attr in attrs:
            sr = cmds.createNode("setRange", name=name.create_name(self.position, self.description, 0, "%sRange" % attr))
            self.range_detail[attr] = sr

            # Create settings node connections
            for settings_attr in ['minX', 'maxX', 'oldMinX', 'oldMaxX']:
                titled_attr = re.sub('([a-zA-Z])', lambda k: k.groups()[0].upper(), settings_attr, 1)
                settings_full_attr = "%s.%s%s" % (self.setup_node, attr, titled_attr)
                cmds.addAttr(self.setup_node, ln="%s%s" % (attr, titled_attr), at="double")
                cmds.setAttr(settings_full_attr, cb=True)
                cmds.setAttr(settings_full_attr, k=True)

                cmds.connectAttr(settings_full_attr, "%s.%s" % (sr, settings_attr))

        # Load settings for part
        if self.settings_file:
            log.debug("Settings file found! Loading...")
            key = os.path.splitext(os.path.basename(self.part_file))[0]
            data = SettingsFileHandler(key).read()
            for full_attr, value in data.items():
                if cmds.objExists(full_attr):
                    cmds.setAttr(full_attr, value)
        else:
            log.warning("No settnings file found, please create before continuing.")
开发者ID:eddiehoyle,项目名称:link,代码行数:34,代码来源:limb.py


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


示例3: switch

def switch(node,attr,value=0,inputNames=list(),inputValues=list()):
    '''
    :param node:
    :param attr:
    :param value:
    :param inputName:
    :param inputValues:
    :return:
    '''

    attrName = "{0}.{1}".format(node,attr)
    choiceName = "{0}_{1}_switch".format(node,attr)
    cmds.createNode("choice",name=choiceName)
    cmds.addAttr(node,ln=attr,at="enum",en=":".join(inputNames),dv=value,keyable=True)

    for i in range(len(inputValues)):
        choiceAttr = "output{0}".format(i)
        cmds.addAttr(choiceName,ln=choiceAttr,at="double3")
        cmds.addAttr(choiceName,ln="{0}x".format(choiceAttr),at="double",p=choiceAttr,dv=inputValues[i][0])
        cmds.addAttr(choiceName,ln="{0}y".format(choiceAttr),at="double",p=choiceAttr,dv=inputValues[i][1])
        cmds.addAttr(choiceName,ln="{0}z".format(choiceAttr),at="double",p=choiceAttr,dv=inputValues[i][2])

        cmds.connectAttr("{0}.{1}".format(choiceName,choiceAttr),"{0}.input[{1}]".format(choiceName,i))

    cmds.connectAttr(attrName,"{0}.selector".format(choiceName),f=True)

    return "{0}.output".format(choiceName)
开发者ID:jdynamite,项目名称:autorigger,代码行数:27,代码来源:attribute.py


示例4: addRmanPrimVar

def addRmanPrimVar(mesh,attrName,attrType='float',paintable=False):
	'''
	'''
	# Prefix attr
	attr = 'rmanF'+attrName
	
	# Data type
	if attrType == 'float': dataType = 'doubleArray'
	if attrType == 'vector': dataType = 'vectorArray'
	if attrType == 'string': dataType = 'stringArray'
	
	# Check mesh
	if not glTools.utils.mesh.isMesh(mesh):
		raise Exception('Mesh "'+mesh+'" does not exist!!')
	
	# Check attr
	if mc.objExists(mesh+'.'+attr):
		raise Exception('Attribute "'+mesh+'.'+attr+'" already exists!!')
	
	# Get shape
	meshShape = mc.listRelatives(mesh,s=True,ni=True,pa=True)
	if not meshShape:
		raise Exception('Unable to determine shape for mesh "'+mesh+'"!!')
	
	# Add attribute
	mc.addAttr(meshShape[0],ln=attr,dt=dataType)
	
	# Make paintable
	if paintable: mc.makePaintable('mesh',attr,attrType=dataType)
开发者ID:RiggingDojoAdmin,项目名称:glTools,代码行数:29,代码来源:primvar.py


示例5: copy_user_attr

def copy_user_attr(selparentshapes, seltargetshapes, copyUV=True):
    listattrvalue = {}
    listdatatype = {}
    userattr = cmds.listAttr(selparentshapes, ud=True)
    if copyUV and cmds.nodeType(seltargetshapes) == 'mesh' and cmds.nodeType(selparentshapes) == 'mesh':
            cmds.transferAttributes(selparentshapes, seltargetshapes, transferUVs=1, transferColors=2, searchMethod=3, sampleSpace=5, flipUVs=False)
    if userattr:
        for attr in userattr:
            nodetype = cmds.nodeType(selparentshapes)
            checkrendershape = cmds.getAttr(selparentshapes + '.intermediateObject')
            if checkrendershape != 1 or nodetype != 'mesh':
                key = attr
                value = cmds.getAttr("%s.%s" % (selparentshapes, key))
                data = cmds.getAttr("%s.%s" % (selparentshapes, key), typ=True)
                listattrvalue[key] = value
                listdatatype[key] = data
    checkrendershape = cmds.getAttr(seltargetshapes + '.intermediateObject')
    if checkrendershape != 1:
        for key in listattrvalue:
            if not cmds.attributeQuery(key, node=seltargetshapes, ex=True):
                if listdatatype[key] == 'string':
                    cmds.addAttr(seltargetshapes, longName=key, dataType=listdatatype[key])
                    cmds.setAttr("%s.%s" % (seltargetshapes, key), listattrvalue[key], type=listdatatype[key])
                else:
                    cmds.addAttr(seltargetshapes, longName=key)
                    cmds.setAttr("%s.%s" % (seltargetshapes, key), listattrvalue[key])
            else:
                cmds.warning('Attribute ' + key + ' already on ' + seltargetshapes)
                if cmds.getAttr("%s.%s" % (seltargetshapes, key), se=True):
                    if listdatatype[key] == 'string':
                        cmds.setAttr("%s.%s" % (seltargetshapes, key), listattrvalue[key], type=listdatatype[key])
                    else:
                        cmds.setAttr("%s.%s" % (seltargetshapes, key), listattrvalue[key])
开发者ID:k0k0c,项目名称:scripts,代码行数:33,代码来源:mayaLgtTmp.py


示例6: connect

	def connect( self, obj, slot=None ):
		'''
		performs the actual connection of an object to a connect slot
		'''
		if not cmd.objExists(obj):
			return -1

		#if the user is trying to connect the trigger to itself, return zero which is the reserved slot for the trigger
		if apiExtensions.cmpNodes( self.obj, obj ):
			return 0

		if slot is None:
			slot = self.nextSlot()

		if slot <= 0:
			return 0

		#make sure the connect isn't already connected - if it is, return the slot number
		existingSlots = self.isConnected(obj)
		if existingSlots:
			return self.getConnectSlots(obj)[0]

		conPrefix = 'zooTrig'
		prefixSize = len(conPrefix)

		slotPath = "%s.%s%d" % (self.obj, conPrefix, slot)
		if not objExists( slotPath ):
			cmd.addAttr(self.obj,ln= "%s%d" % (conPrefix, slot), at='message')

		cmd.connectAttr( "%s.msg" % obj, slotPath, f=True )
		self.cacheConnect( slot )

		return slot
开发者ID:GuidoPollini,项目名称:MuTools,代码行数:33,代码来源:triggered.py


示例7: add_wf_mat_name_attr

def add_wf_mat_name_attr(*args):
	r'''addes a material name attribute of WFMaterialName based on diffuse file connection
	'''
	mat_pairs=[]
	mats = cmds.ls(mat=True)
	for mat in mats:
		_file = cmds.listConnections('%s.color' % mat)
		if _file :
				tex_path =  cmds.getAttr(_file[0] + '.fileTextureName')
				idx = tex_path.lower().find('assets') 
				if idx != -1:
					new_name = '/' + tex_path[idx+7:-6]
					attr_list = cmds.listAttr(mat)
					if not ('WFMaterialName' in attr_list):
						print 'Attribute not in list, making attribute' 
						cmds.addAttr(mat, dt="string", ln="WFMaterialName")
						
					cmds.setAttr(mat + '.WFMaterialName', new_name, type="string" )
					# print ([mat, new_name])
					mat_pairs.append([mat, new_name])
		

				else:
					print 'Material: \n  %s' % mat
					print 'String \"assets\" does not exist in the path\n  %s' % tex_path
	return mat_pairs
开发者ID:adityavs,项目名称:worldforge_pipeline,代码行数:26,代码来源:wf_pipeline.py


示例8: _create_meta_data

 def _create_meta_data(self):
     """
     Creates a network node to hold the meta data for the rig.
     """
     network_node = cmds.createNode("network")
     meta_node_name = self._get_unique_name("metaNode", "DyMETA")
     meta_node = cmds.rename(network_node, meta_node_name)
     data = {
             "rootGroup" : self.root_group,
             "rigName" : self.rig_name,
             "parentControl" : self.parent_control,
             "controls" : self.controls,
             "pointLock" : self.point_lock,
             "startFrame" : self.start_frame,
             "endFrame" : self.end_frame,
             "dynamicControl" : self.dynamic_control,
             "metaNode" : meta_node,
             "hairSystem" : self.hair_system}
     # build data
     for meta, data in data.iteritems():
         if meta == "controls":
             cmds.addAttr(meta_node, dt="stringArray", ln=meta)
             cmds.setAttr("{0}.{1}".format(meta_node, meta),
                          *([len(data)]+data), type="stringArray")
             continue
         cmds.addAttr(meta_node, dt="string", ln=meta)
         cmds.setAttr("{0}.{1}".format(meta_node, meta),
                      data, type="string")
开发者ID:ABCTD,项目名称:abc_pipe,代码行数:28,代码来源:overlap_tool.py


示例9: addIdAttr

 def addIdAttr(self,*args):
     selList = self.listSelected()
     meshList = self.getMeshList(selList)
     # add attribute to selected meshes
     for mesh in meshList:
         if not mc.objExists(mesh+'.'+self.idGroupAttr):
             mc.addAttr(mesh,ln = self.idGroupAttr,sn = self.idGroupAttr,at = "long",dv = -1)
开发者ID:jackieliao67,项目名称:mtoaSetManager,代码行数:7,代码来源:matteGroupManager.py


示例10: createAssetSetFromSelect

def createAssetSetFromSelect(name = 'asset1', type = ''):
    asset = mc.sets(name = "%s" % name)
    mc.addAttr(asset, longName = 'asset', niceName = "Asset", dataType = 'string')
    mc.addAttr(asset, longName = 'type', niceName = "Type", dataType = 'string')
    mc.setAttr("%s.asset" % asset, name, type = "string")
    mc.setAttr("%s.type" % asset, type, type = "string")
    return asset
开发者ID:akoon,项目名称:OldPipeline,代码行数:7,代码来源:masset.py


示例11: addSymEdgeAttr

def addSymEdgeAttr(edge):
	'''
	Add mesh symmetry edge attribute based on specified mesh edge.
	@param edge: Mesh edge that defined the center edge row of a symmetrical mesh
	@type edge: str
	'''
	# Check Edge
	edge = mc.filterExpand(edge,ex=True,sm=32) or []
	if not edge:
		raise Exception('No valid mesh edge selected!')
	if len(edge) > 1:
		print('Multiple mesh edges found! Using first edge only ("'+edge[0]+'").')
	edge = edge[0]
	
	# Get Edge Mesh
	mesh = mc.ls(edge,o=True) or []
	if not mesh:
		raise Exception('Unable to determine mesh from edge!')
	if len(mesh) > 1:
		print('Multiple mesh objects found from edge!')
	mesh = mesh[0]
	
	# Get Edge ID
	edgeID = glTools.utils.component.index(edge)
	
	# Add Attribute
	symAttr = 'symmetryEdgeId'
	if not mc.objExists(mesh+'.'+symAttr):
		mc.addAttr(mesh,ln=symAttr,at='long',min=0,dv=edgeID)
	mc.setAttr(mesh+'.'+symAttr,edgeID)
	
	# Return Result
	return mesh+'.'+symAttr
开发者ID:auqeyjf,项目名称:glTools,代码行数:33,代码来源:edgeFlowMirror.py


示例12: rsChName

def rsChName(i_s_textField, s_name):
    l_oSels = rsObjList()
    i_LockState = cmds.getAttr(l_oSels[2], lock=True)
    if i_LockState:
        cmds.setAttr(l_oSels[2], lock=False)
    if s_name == "NewName":
        s_NewName = l_oSels[0] + "." + i_s_textField
        cmds.renameAttr(l_oSels[2], i_s_textField)
        if i_LockState:
            cmds.setAttr(s_NewName, lock=True)
        s_search = i_s_textField
    else:
        cmds.addAttr(l_oSels[2], edit=True, niceName=i_s_textField)
        if i_LockState:
            cmds.setAttr(l_oSels[2], lock=True)
        s_search = l_oSels[1]
    l_ChannelAtList = rsChannelAtList()
    l_AttrKey = l_ChannelAtList[0]
    l_AttrKeyHidden = l_ChannelAtList[1]
    if l_AttrKey or l_AttrKeyHidden:
        cmds.textScrollList("rsAttributeScroll", edit=True, removeAll=True, append=l_AttrKey)
        cmds.textScrollList("rsAttributeScrollHidden", edit=True, removeAll=True, append=l_AttrKeyHidden)
    cmds.select(cl=True)
    cmds.select(l_oSels[0], r=True)
    rsSearchInScroll(s_search)
    return True
开发者ID:RigStudio,项目名称:rsEditAttributes,代码行数:26,代码来源:rsEditAttributes.py


示例13: rsChangeCheck

def rsChangeCheck(i_b_state, i_s_floatField):
    if i_s_floatField == "rsMinField":
        i_b_state = cmds.checkBox("rsMinBox", query=True, value=True)
    else:
        i_b_state = cmds.checkBox("rsMaxBox", query=True, value=True)
    l_oSels = rsObjList()
    if i_b_state == True:
        if i_s_floatField == "rsMinField":
            b_minimum = cmds.attributeQuery(l_oSels[1], node=l_oSels[0], minExists=True)
            f_atValue = 0.0
            if b_minimum == 1:
                f_atValue = (cmds.attributeQuery(l_oSels[1], node=l_oSels[0], minimum=True))[0]
            else:
                cmds.addAttr(l_oSels[2], edit=True, hasMinValue=True)
        if i_s_floatField == "rsMaxField":
            b_maximum = cmds.attributeQuery(l_oSels[1], node=l_oSels[0], maxExists=True)
            f_atValue = 1.0
            if b_maximum == 1:
                f_atValue = (cmds.attributeQuery(l_oSels[1], node=l_oSels[0], maximum=True))[0]
            else:
                cmds.addAttr(l_oSels[2], edit=True, hasMaxValue=True)
                cmds.addAttr(l_oSels[2], edit=True, maxValue=f_atValue)
        cmds.floatField(i_s_floatField, edit=True, value=f_atValue, enable=True)
    else:
        cmds.floatField(i_s_floatField, edit=True, value=0, enable=False)
        if i_s_floatField == "rsMinField":
            cmds.addAttr(l_oSels[2], edit=True, hasMinValue=False)
        else:
            cmds.addAttr(l_oSels[2], edit=True, hasMaxValue=False)
    return True
开发者ID:RigStudio,项目名称:rsEditAttributes,代码行数:30,代码来源:rsEditAttributes.py


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


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


示例16: pyToAttr

def pyToAttr(objAttr, data):
	"""
	Write (pickle) Python data to the given Maya obj.attr.  This data can
	later be read back (unpickled) via attrToPy().

	Arguments:
	objAttr : string : a valid object.attribute name in the scene.  If the
		object exists, but the attribute doesn't, the attribute will be added.
		The if the attribute already exists, it must be of type 'string', so
		the Python data can be written to it.
	data : some Python data :  Data that will be pickled to the attribute
		in question.
	"""
	obj, attr = objAttr.split('.')
	# Add the attr if it doesn't exist:
	if not cmds.objExists(objAttr):
		cmds.addAttr(obj, longName=attr, dataType='string')
	# Make sure it is the correct type before modifing:
	if cmds.getAttr(objAttr, type=True) != 'string':
		raise Exception("Object '%s' already has an attribute called '%s', but it isn't type 'string'"%(obj,attr))

	# Pickle the data and return the coresponding string value:
	stringData = cPickle.dumps(data)
	# Make sure attr is unlocked before edit:
	cmds.setAttr(objAttr, edit=True, lock=False)
	# Set attr to string value:
	cmds.setAttr(objAttr, stringData, type='string')
	# And lock it for safety:
	cmds.setAttr(objAttr, edit=True, lock=True)
开发者ID:DavideAlidosi,项目名称:May9,代码行数:29,代码来源:utils.py


示例17: cleanup

    def cleanup(self, version = 2.0):
        #hide groups and lock attributes
        cmds.setAttr(self.negativeBshpesGrp + ".v", 0)
        cmds.setAttr(self.resultBshpesGrp + ".v", 0)

        for i in cmds.ls(self.eTools, self.engineersToolsGrp, self.doNotTouchGrp, self.shotFinalGrp, self.mainBshpesGrp, self.negativeBshpesGrp, self.sculptBshpesGrp, self.resultBshpesGrp, "*Negative*", "*Sculpt*", "*Result*"):
            try:
                for axis in "xyz":
                    cmds.setAttr(i + ".t" + axis, lock = 1, keyable = 0)
                    cmds.setAttr(i + ".r" + axis, lock = 1, keyable = 0)
                    cmds.setAttr(i + ".s" + axis, lock = 1, keyable = 0)
                cmds.setAttr(i + ".v", keyable = 0)
                cmds.setAttr(i + ".ihi", 0)
            except:
                pass

        #hide isHistoricallyInteresting
        for i in cmds.ls("blendShape*", "tweak*"):
            cmds.setAttr(i + ".ihi", 0)


        #add versionNumber of the SHOTFINAL script
        if not cmds.objExists(self.engineersToolsGrp + ".version"):
            cmds.addAttr(self.engineersToolsGrp, longName = "version", shortName = "version", attributeType = "float", keyable = 1)
            cmds.setAttr(self.engineersToolsGrp + ".version", version, edit  = 1, channelBox = 1, lock = 1)


        #select the engineersTools group
        cmds.select(self.sculptTools)
开发者ID:jonntd,项目名称:Public,代码行数:29,代码来源:shotFinalingTools.py


示例18: updateOrigNamesFormat

	def updateOrigNamesFormat(self,objectList=[]):
		'''
		Update a combined meshes origNames attribute to the newest format.
		@param objectList: list of mesh objects to update origNames attribute on.
		@type objectList: list
		'''
		# Confirm list
		if type(objectList) == str:
			objectList = [objectList]
		
		# Iterate through object list
		for obj in objectList:
			
			# Check origNames attribute
			if not mc.objExists(obj+'.origNames'):
				raise Exception('Object '+obj+' does not have a "origNames" attribute!')
			if mc.addAttr(obj+'.origNames',q=True,multi=True):
				print(obj+'.origNames is already in the correct format.')
				continue
			
			# Extract original names list from old format
			origNamesList = []
			index = 0
			while True:
				if mc.objExists(obj+'.origNames.origNames_'+str(index)):
					origNamesList.append(mc.getAttr(obj+'.origNames.origNames_'+str(index)))
					index+=1
				else: break
			
			# Re-create the origNames attribute in the new format
			mc.deleteAttr(obj+'.origNames')
			mc.addAttr(obj,ln='origNames',dt='string',multi=True)
			for i in range(len(origNamesList)):
				mc.setAttr( obj+'.origNames['+str(i)+']', origNamesList[i], type='string')
开发者ID:auqeyjf,项目名称:glTools,代码行数:34,代码来源:meshCombine.py


示例19: save_scene

def save_scene(search_key, context, description, all_process):

    # add info about particular scene
    skey_link = 'skey://{0}&context={1}'.format(search_key, context)
    if not cmds.attributeQuery('tacticHandler_skey', node='defaultObjectSet', exists=True):
        cmds.addAttr('defaultObjectSet', longName='tacticHandler_skey', dataType='string')
    cmds.setAttr('defaultObjectSet.tacticHandler_skey', skey_link, type='string')

    # get template names for scene and playblast image
    temp_dir = env.Env().get_temp_dir()
    random_uuid = uuid.uuid4()

    types = {
        'mayaBinary': 'mb',
        'mayaAscii': 'ma',
    }
    temp_file = '{0}/{1}.ma'.format(temp_dir, random_uuid)
    temp_playblast = '{0}/{1}.jpg'.format(temp_dir, random_uuid)

    # rename file, save scene, playblast, get saving format
    cmds.file(rename=temp_file)
    cmds.file(save=True, type='mayaAscii')
    current_frame = cmds.currentTime(query=True)
    cmds.playblast(
        forceOverwrite=True,
        format='image',
        completeFilename=temp_playblast,
        showOrnaments=False,
        widthHeight=[960, 540],
        sequenceTime=False,
        frame=[current_frame],
        compression='jpg',
        offScreen=True,
        viewer=False,
        percent=100
    )

    # check in snapshot
    snapshot = tc.checkin_snapshot(search_key, context, temp_file, file_type='maya', is_current=True,
                                   description=description)

    # from pprint import pprint
    # pprint(snapshot)
    # retrieve checked in snapshot file info
    asset_dir = env.Env().get_asset_dir()
    file_sobject = snapshot['__file_sobjects__'][0]
    relative_dir = file_sobject['relative_dir']
    file_name = file_sobject['file_name']

    # make proper file path, and dir path to set workspace
    new_file = '{0}/{1}/{2}'.format(asset_dir, relative_dir, file_name)
    split_path = relative_dir.split('/')
    dir_path = '{0}/{1}'.format(asset_dir, '{0}/{1}/{2}'.format(*split_path))
    set_workspace(dir_path, all_process)

    # check in playblast
    tc.checkin_playblast(snapshot['code'], temp_playblast)

    # set proper scene name
    cmds.file(rename=new_file)
开发者ID:heylenz,项目名称:TACTIC-Handler,代码行数:60,代码来源:maya_functions.py


示例20: combine

	def combine(self, objs=[], new_name="", keepHistory=0):
		'''
		Combines the geometry and stores the names.
		This is useful for speeding up the rigs and seperating in a predictible way.
		@param objs: Mesh objects to combine
		@type objs: list
		@param new_name: New name for the combined mesh
		@type new_name: str
		@param keepHistory: Maintain history after function has completed
		@type keepHistory: bool
		'''
		# Check input arguments
		if not objs:
			raise Exception('Input list "objs" is not a valid list!')
		for obj in objs:
			if not mc.objExists(obj):
				raise Exception('Object '+obj+' does not exist!')
		if mc.objExists(new_name):
			raise Exception('An object of name '+new_name+' already exists! Please choose another name!')
		
		# Combine multiple mesh objects to a single mesh
		new_obj = mc.polyUnite(objs, n=new_name)
		mc.addAttr( new_obj[0], ln='origNames', dt='string', multi=True)
		# Recond original names list on new mesh transform
		for i in range(len(objs)):
			mc.setAttr( new_obj[0]+'.origNames['+str(i)+']', objs[i], type='string')
		# Delete history
		if not keepHistory : mc.delete(new_obj[1])
		mc.delete(objs)
		
		return new_obj[0]
开发者ID:auqeyjf,项目名称:glTools,代码行数:31,代码来源:meshCombine.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python cmds.aimConstraint函数代码示例发布时间:2022-05-27
下一篇:
Python cmds.about函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap