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


Python cmds.namespace函数代码示例

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


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

示例1: importSkinByRef

def importSkinByRef(ref, file, skip=[], **kwargs):
    """Import skin for every dag node in reference."""

    if not os.path.exists(file):
        rigUtils.log('Skin file not found - skipping: %s' % file)
        return

    rigUtils.log('Reading file: %s' % file)

    f = open(file, 'r')
    j = json.loads(f.read())
    f.close()

    cmds.namespace(set=ref)
    dagnodes = cmds.namespaceInfo(lod=True)
    cmds.namespace(set=':')

    skinned = []

    for dagnode in dagnodes:
        if skip:
            if dagnode in skip:
                continue
        if dagnode in j:
            dict = j[dagnode]
            try: skindict = dict['skinCluster']
            except: continue
            importSkin(skindict, dagnode, **kwargs)
            skinned.append(dagnode)

    return skinned
开发者ID:timm-gitHub,项目名称:fbRepo,代码行数:31,代码来源:bodyIO.py

示例2: resolveNamespaceClashes

	def resolveNamespaceClashes(self, tempNamespace):
		returnNames = []
		
		cmds.namespace(setNamespace=tempNamespace)
		namespaces = cmds.namespaceInfo(listOnlyNamespaces=True)
		cmds.namespace(setNamespace=':')
		existingNamespaces = cmds.namespaceInfo(listOnlyNamespaces=True)
		
		for i in range(len(namespaces)):
			namespaces[i] = namespaces[i].partition(tempNamespace+ ':')[2]
			
		for name in namespaces:
			newName = str(name)
			oldName = tempNamespace + ':' + name
			
			if name in existingNamespaces:
				highestSuffix = utils.findHighestTrailingNumber(existingNamespaces, name+'_')
				highestSuffix += 1
			
				newName = str(name) + '_' + str(highestSuffix)
			
			returnNames.append([oldName,newName])
			
		self.resolveNameChangeMirrorLinks(returnNames,tempNamespace)
		
		self.renameNamespaces(returnNames)
		
		return returnNames
开发者ID:pouyaz123,项目名称:Python-character-pipeline,代码行数:28,代码来源:blueprint_UI.py

示例3: searchCharsName

def searchCharsName():
    """检索当前场景中的所有角色名

    Description:
        根据绑定文件的命名规范与reference原则,从命名空间中就可获得角色名称

    Arguments:
        无

    Returns:
        allCharsNameList:所有角色名列表(无重复)
    """
    cmds.namespace(set = ":")
    allNamespace = cmds.namespaceInfo(listOnlyNamespaces = True)  #拿到所有根目录下的命名空间名称
    allCharsName = []
    
    for eachNamespace in allNamespace:
        #拿到带有_Char_的命名空间名称,从中拿到角色名
        
        if eachNamespace.find("_chr_") < 0:
            print "This Is Not A Char!"            
        else:
            namesapceWithChar = eachNamespace
            charName = namesapceWithChar.split("_")[2]  #charName存放角色名
            allCharsName.append(charName)

    allCharsNameList = cT.delDupFromList(allCharsName)  #调用函数去除list中的重复元素
    
    return allCharsNameList
开发者ID:chloechan,项目名称:clothAndHair,代码行数:29,代码来源:dynInfor.py

示例4: installModule

	def installModule(self, module, *arg):
		basename = 'instance_'
	
		cmds.namespace(setNamespace=":")
		namespaces = cmds.namespaceInfo(listOnlyNamespaces=True)
		
		for i in range(len(namespaces)):
			if namespaces[i].find('__') != -1:
				namespaces[i] = namespaces[i].partition('__')[2]

		newSuffix = utils.findHighestTrailingNumber(namespaces, basename) + 1
		
		userSpecName = basename + str(newSuffix)
		
		hookObj = self.findHookObjectFromSelection()
	
		mod = __import__('Blueprint.'+ module,{},{},[module])
		reload(mod)
		
		moduleClass = getattr(mod, mod.CLASS_NAME)
		moduleInstance = moduleClass(userSpecName, hookObj)
		moduleInstance.install()
		
		#this is to make sure move tool is selected by default
		moduleTransform = mod.CLASS_NAME + '__' + userSpecName + ':module_transform'
		cmds.select(moduleTransform, replace=True)
		cmds.setToolTo('moveSuperContext')
开发者ID:pouyaz123,项目名称:Python-character-pipeline,代码行数:27,代码来源:blueprint_UI.py

示例5: deleteModule

 def deleteModule(self, *args):
     """ Delete the Guide, ModuleLayout and Namespace.
     """
     # delete mirror preview:
     try:
         cmds.delete(self.moduleGrp[:self.moduleGrp.find(":")]+"_MirrorGrp")
     except:
         pass
     # delete the guide module:
     utils.clearNodeGrp(nodeGrpName=self.moduleGrp, attrFind='guideBase', unparent=True)
     # clear default 'dpAR_GuideMirror_Grp':
     utils.clearNodeGrp()
     # remove the namespaces:
     allNamespaceList = cmds.namespaceInfo(listOnlyNamespaces=True)
     if self.guideNamespace in allNamespaceList:
         cmds.namespace(moveNamespace=(self.guideNamespace, ':'), force=True)
         cmds.namespace(removeNamespace=self.guideNamespace, force=True)
     try:
         # delete the moduleFrameLayout from window UI:
         cmds.deleteUI(self.moduleFrameLayout)
         self.clearSelectedModuleLayout()
         # edit the footer A text:
         self.currentText = cmds.text("footerAText", query=True, label=True)
         cmds.text("footerAText", edit=True, label=str(int(self.currentText[:self.currentText.find(" ")]) - 1) +" "+ self.langDic[self.langName]['i005_footerA'])
     except:
         pass
     # clear module from instance list (clean dpUI list):
     delIndex = self.dpUIinst.moduleInstancesList.index(self)
     self.dpUIinst.moduleInstancesList.pop(delIndex)
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:29,代码来源:dpBaseClass.py

示例6: __init__

 def __init__(self, dpUIinst, langDic, langName, userGuideName, rigType, CLASS_NAME, TITLE, DESCRIPTION, ICON):
     """ Initialize the module class creating a button in createGuidesLayout in order to be used to start the guide module.
     """
     # defining variables:
     self.dpUIinst = dpUIinst
     self.langDic = langDic
     self.langName = langName
     self.guideModuleName = CLASS_NAME
     self.title = TITLE
     self.description = DESCRIPTION
     self.icon = ICON
     self.userGuideName = userGuideName
     self.rigType = rigType
     # defining namespace:
     self.guideNamespace = self.guideModuleName + "__" + self.userGuideName
     # defining guideNamespace:
     cmds.namespace(setNamespace=":")
     self.namespaceExists = cmds.namespace(exists=self.guideNamespace)
     self.guideName = self.guideNamespace + ":Guide"
     self.moduleGrp = self.guideName+"_Base"
     self.radiusCtrl = self.moduleGrp+"_RadiusCtrl"
     self.annotation = self.moduleGrp+"_Ant"
     if not self.namespaceExists:
         cmds.namespace(add=self.guideNamespace)
         # create GUIDE for this module:
         self.createGuide()
     # create the Module layout in the mainUI - modulesLayoutA:        
     self.createModuleLayout()
     # update module instance info:
     self.updateModuleInstanceInfo()
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:30,代码来源:dpBaseClass.py

示例7: _fixTheFuckingCores

	def _fixTheFuckingCores(self):
		"""
		This is used to clean sweep the static scenes and remove the duplicate Namespaces and reconnect the bases to the duplicates
		"""

		removedNameSpaces = []
		## Remove duplicate root core namespaces
		getAllNameSpaces = cmds.namespaceInfo(listOnlyNamespaces = True)
		for eachNS in getAllNameSpaces:
			if eachNS.endswith('1'):
				print 'Removing %s' % eachNS
				cmds.namespace(removeNamespace = eachNS, mergeNamespaceWithRoot = True)
				removedNameSpaces.append(eachNS.replace('1', '').replace('_CORE', ''))

		## Remove duplicate base cores
		for each in cmds.ls(type = 'core_archive'):
			if '1'in each:
				print 'Cleaned rootCore %s from scene...' % each
				cmds.delete(each)

		## Now find all geo with the core name in it and proceess it for reconnection
		for eachCore in removedNameSpaces:
			#print eachCore
			## Check child _hrc grps for processing
			getAllGeo = [eachGeo for eachGeo in cmds.ls('*%s*' % eachCore) if cmds.nodeType(eachGeo) == 'transform']
			for eachGeo in getAllGeo:
				self._reconnectDuplicates(eachGeo, '%s_CORE_Geoshader' % eachCore)

		coreLib.cleanupDeadCoreArchives()
开发者ID:vipul-rathod,项目名称:lsapipeline,代码行数:29,代码来源:app.py

示例8: namespaceList

def namespaceList(current= None):
	"""
	"""
	if not current:
		cmds.namespace(set = ':')

	return cmds.namespaceInfo(lon= 1, r= 1, an= 1)
开发者ID:davidpower,项目名称:MS_Research,代码行数:7,代码来源:mGeneral.py

示例9: buildScene

    def buildScene(self):
        MayaCmds.file(new=True, force=True)

        MayaCmds.namespace(addNamespace='foo')
        MayaCmds.namespace(addNamespace='bar')
        MayaCmds.createNode('transform', name='foo:a')
        MayaCmds.createNode('transform', name='bar:a')
        MayaCmds.createNode('transform', name='a')
        MayaCmds.polyPlane(sx=1, sy=1, w=1, h=1, ch=0, n='foo:b')
        MayaCmds.polyPlane(sx=1, sy=1, w=1, h=1, ch=0, n='bar:b')
        MayaCmds.polyPlane(sx=1, sy=1, w=1, h=1, ch=0, n='b')
        MayaCmds.parent('foo:b', 'foo:a')
        MayaCmds.parent('bar:b', 'bar:a')
        MayaCmds.parent('b', 'a')

        MayaCmds.select('foo:b.vtx[0:8]')
        MayaCmds.setKeyframe(t=[1, 4])
        MayaCmds.scale(0.1, 0.1, 0.1, r=True)
        MayaCmds.setKeyframe(t=2)

        MayaCmds.select('bar:b.vtx[0:8]')
        MayaCmds.setKeyframe(t=[1, 4])
        MayaCmds.scale(2, 2, 2, r=True)
        MayaCmds.setKeyframe(t=2)

        MayaCmds.select('b.vtx[0:8]')
        MayaCmds.setKeyframe(t=[1, 4])
        MayaCmds.scale(5, 5, 5, r=True)
        MayaCmds.setKeyframe(t=2)
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:29,代码来源:connectNamespace_test.py

示例10: deleteNS

def deleteNS():
    sel_namespace = cmds.ls(sl=True)[0]
    NS = sel_namespace.rsplit(':',1)[0]
    if not cmds.namespace(ex=NS):
        raise Exception('Namespace "'+NS+'" does not exist!')
    cmds.namespace(mv=[NS,':'],f=True)
    cmds.namespace(rm=NS)
开发者ID:PertyCoy,项目名称:programming,代码行数:7,代码来源:deleteNS.py

示例11: renameAllNodeInNamespace

def renameAllNodeInNamespace( ns='' ) :

	# Remove every nodes that belong to the given namespace.
	# Input		: Namespace
	# Output	: Empty namespace
	
	nodes = mc.ls( '%s:*' % ns , l=True )
	mc.namespace( set=':' )

	if nodes :
		# If current namespace contains nodes,
		# delete them.
		for node in nodes :

			if mc.objExists( node ) :

				lockState = mc.lockNode( node , q=True )[0]

				if lockState :
					mc.lockNode( node , l=False )
				newName = addElementToName( node.split( ':' )[-1] , ns )
				print newName
				try :
					mc.rename( node , newName )
				except :
					pass
开发者ID:myCodeTD,项目名称:pkmel,代码行数:26,代码来源:rigTools.py

示例12: getCharacterInfo

def getCharacterInfo():
    cmds.namespace(set=":")
    namespaces = cmds.namespaceInfo(lon=True)
    characterName = []
    for name in namespaces: 
        """ TODO: """
        """ I need a global check for valid characters in the scene """
        characterContainer = (name + ":character_container")
        setupContainer = name.replace("Character__", "Export__")
        setupContainer = (setupContainer + ":Setup")

        if cmds.objExists (characterContainer):
            fullCharName = name
            tmpCharName = name.split("__")[1]
            tmpCharName = tmpCharName[:tmpCharName.rfind("_")]
            characterName = tmpCharName
            return (characterName, characterContainer, fullCharName, setupContainer)  
                  
        else:
            characterContainer = 'Character__tmp_1:character_container'
            fullCharName = name
            tmpCharName = name.split("__")[1]
            tmpCharName = tmpCharName[:tmpCharName.rfind("_")]
            characterName = tmpCharName

            return (characterName, characterContainer, fullCharName, setupContainer)
            # Warn no character in the scene
            #charConfirm = ("No character exists in this scene")
            #cmds.confirmDialog(messageAlign="center", title="Create Directory", message= charConfirm)
            characterName = 'Character__tmp'
            return characterName
开发者ID:griffinanimator,项目名称:MPR,代码行数:31,代码来源:turbineSpecificUtils.py

示例13: process

def process( call, *args):
	# Selection
	intialSelection = cmds.ls(selection=True, flatten=True)
	selections = intialSelection[:]
	# Input Values from UI
	inputName = ['placeholder'] # needs to be a list fed into it to work
	inputName[0] = cmds.textField("inputField", q=True, text = True)
	old = cmds.textField("replaceField", q=True, text = True)
	new = cmds.textField("withField", q=True, text = True)
	# Assign the Rename Class 
	D = Rename(selections, inputName )
	if old: # if there is data in the replaceField txt box, then run the replacement code
		for i in range( len (selections) ):
			findTxt = D.reFunction(D.getAfterNamespace(i), old)
			replacementName = D.getAfterNamespace(i)[ : findTxt [0][0] ] + new + D.getAfterNamespace(i)[ findTxt [0][1] : ]
			cmds.rename(selections[i], D.getNamespace(i) + replacementName)
	else:
		for i in range( len (selections) ):
			X = D.processNamespace(i)
			if X == ':': X = '::' # This prevents the root namespace from getting lost in the cutoff [:-1] use X[:-1] instead of D.processNamespace(i) [:-1]
			if cmds.namespace(exists = X [:-1] ) != True: # creates new namespace if doesn't already exist
				print ' creating new namespace'
				cmds.namespace(addNamespace = X [:-1] ) # create namespace if doesn't already exist
			cmds.rename( D.selection[i] , ':' + D.processNamespace(i) + D.processRename(i) )
			cmds.namespace(set = ':') # set namespace back to root so any new object created is under the root
	if call == 'NA':
		cmds.warning('no exit call, window stays open')
	elif call == 'exit':
		cmds.warning('exit called, closing rename window')
		cmds.evalDeferred('cmds.deleteUI("renameUI")')
		#cmds.deleteUI(window)
开发者ID:jricker,项目名称:JR_Maya,代码行数:31,代码来源:JR_rename_tool_backup.py

示例14: deleteNsContents

    def deleteNsContents(self, nameSpace):
        mc.namespace(set=":")
        mc.namespace(set=":"+nameSpace)
        if self.debug: print"current ns: ", mc.namespaceInfo(currentNamespace=True)
        nsContent = mc.namespaceInfo(ls=True, listOnlyDependencyNodes=True)

        if not nsContent:
            return

        for i in mc.namespaceInfo(ls=True, listOnlyDependencyNodes=True):
            
            delStr = i.split(":")[-1]
            
            try:
                print "deleting:", delStr
                #print mc.nodeType(i)
                mc.delete(i)
                self.count += 1

            except:
                if self.debug:print "can not delete: ", i
                pass

        if self.debug: print "renaming namespace: ", nameSpace
        self.setNsCleaned(nameSpace)
开发者ID:chichang,项目名称:ccLookdevToolkit,代码行数:25,代码来源:sceneBuildPostCleanup.py

示例15: instanceAsset

def instanceAsset(namespace=""):
    """Find new namespace"""
    ns = namespace
    name = "%s:root" % ns

    i = 1
    while cmds.objExists(name):
        ns = "%s%d" % (namespace, i)
        name = "%s:root" % ns
        i += 1

    """Make instance"""
    cmds.namespace(add=ns)
    root = cmds.instance("%s:root" % namespace, name=name)[0]

    """Get model_grp path"""
    model_grp = "%s:root|%s:master_trs|%s:shot_trs|%s:aux_trs|%s:model_grp" % (
        ns,
        namespace,
        namespace,
        namespace,
        namespace,
    )

    """Lock attributes"""
    cmds.setAttr("%s.%s" % (root, "asset"), lock=True)
    cmds.setAttr("%s.%s" % (root, "texturever"), lock=True)
    cmds.setAttr("%s.inheritsTransform" % model_grp, 0)
开发者ID:pixo,项目名称:hk,代码行数:28,代码来源:am_maya.py


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