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


Python cmds.rename函数代码示例

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


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

示例1: SetupAlembic

def SetupAlembic(alembicFile, shaderFile):

    # reference alembic file
    filename = os.path.basename(alembicFile)
    newNodes = cmds.file(alembicFile, reference=True, namespace=filename,
                         groupReference=True, groupName='NewReference',
                         returnNewNodes=True)

    alembicRoot = None
    for node in newNodes:
        if node == '|NewReference':
            alembicRoot = pm.PyNode(node)
            cmds.rename('%s:grp' % filename)

    # reference shader file
    filename = os.path.basename(shaderFile)
    newNodes = cmds.file(shaderFile, reference=True, namespace=filename,
                         groupReference=True, groupName='NewReference',
                         returnNewNodes=True)

    shaderRoot = None
    for node in newNodes:
        if node == '|NewReference':
            shaderRoot = pm.PyNode(node)
            cmds.rename('%s:grp' % filename)

    # connecting shader to alembic
    Connect(alembicRoot, shaderRoot)
    alembicRoot.v.set(0)
开发者ID:mkolar,项目名称:Tapp,代码行数:29,代码来源:utils.py

示例2: duplicate_this

    def duplicate_this(self, input_object, copy_name='cpy_'):
        '''
        Desc:
        return a obj that is the copy of inputObject with a name defined in nameOfCopy

        Parameter:
        input_object = the object to be copied
        copy_name = the copy name

        Return:
        the obj copied from the original with the new name
        '''

        if input_object:
            #cmds.select(input_object)
            copy_object = cmds.duplicate(input_object, smartTransform=True, name = copy_name, renameChildren = True)
            copy_object[0] = cmds.rename(copy_object[0], copy_name+input_object)
            #print('DEBUG copy object: ', copy_object)

            # Search all children of the current object for renaming
            hierarchy = cmds.listRelatives(copy_object, c=True)
            if hierarchy:
                for child in hierarchy:
                    cmds.rename(child, copy_name+child[:-1])

                KstOut.debug(KstMaya._debug, str(copy_object[0])+" duplicated from "+str(input_object))
                return copy_object
        else:
            KstOut.debug(KstMaya._debug, ' inputObject empty, check selection, or array')
开发者ID:Leopardob,项目名称:Kistie,代码行数:29,代码来源:KstMaya.py

示例3: maya_move

def maya_move(angular_velocity, time_step):
            
    objects = cmds.ls(sl=True)
    if objects == []:
        print('* Please select at least an object.')
        return
        
    trajectory = cmds.ls('trajectory')
    
    for i, o in enumerate(objects):
        x = cmds.getAttr(o + '.translateX')
        y = cmds.getAttr(o + '.translateY')
        z = cmds.getAttr(o + '.translateZ')
    
        loc = [x, y, z]
        state = make_state(loc)
                
        state = simulate_circle(state, angular_velocity, time_step)
        
        old_loc = loc
        loc = get_location(state)
        
        cmds.select(o)
        cmds.move(loc[0], loc[1], loc[2])
        
        # draw trajectory for the first object
        if i == 0:
            if trajectory == []:
                cv = cmds.curve(point=[old_loc, loc], degree=1)                
                cmds.rename(cv, 'trajectory')
            else:
                cmds.curve('trajectory', point=[loc], degree=1, append=True)
        
    # keep all objects selected
    cmds.select(objects)
开发者ID:HerrR,项目名称:CS3242-3D-Modeling-and-Animation,代码行数:35,代码来源:circle_empty.py

示例4: bdReplaceSelected

	def bdReplaceSelected(self,*args):
		selectedObj = []
		selectedObj = cmds.ls(selection = True,ap=True )	
		strSearch = str(self.inputSearch.text())
		strReplace = str(self.inputReplace.text())
		strPrefix = str(self.inputPrefixReplace.text())
		strSufix = str(self.inputSufixReplace.text())
		
		strNewNames = []

		if strSearch != '':
			self.listPreview.clear()
			for obj in selectedObj:
				newName = strPrefix + obj.split('|')[-1].replace(strSearch,strReplace) + strSufix
				self.listPreview.addItem(newName)
				strNewNames.append(newName)
		else:
			if strPrefix != '' or strSufix != '':
				self.listPreview.clear()
				for obj in selectedObj:
					newName = strPrefix + obj.split('|')[-1] + strSufix
					self.listPreview.addItem(newName)
					strNewNames.append(newName)				

		strNewNames = list(reversed(strNewNames))
		strSelected = list(reversed(selectedObj))
		for i in range(len(strNewNames)):
			print 'new name for %s is %s'%(strSelected[i],strNewNames[i])
			cmds.rename(strSelected[i],strNewNames[i])	
开发者ID:Mortaciunea,项目名称:bdScripts,代码行数:29,代码来源:bdMultiRename_v01.py

示例5: cleanClashingElements

 def cleanClashingElements(self, origRenderElements, newRenderElements):
     for newElement in newRenderElements:
         if clashNameSpace in newElement:
             if not newElement.split(clashNameSpace)[-1] in origRenderElements:
                 classingBaseName = newElement.split(clashNameSpace + "_")[-1]
                 cmds.delete(classingBaseName)
                 cmds.rename(newElement, classingBaseName)
开发者ID:davidwilliamsDK,项目名称:maya,代码行数:7,代码来源:dsVrayElementsTool.py

示例6: doNameObject

def doNameObject(obj,sceneUnique = False):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Names an object, when forceOverride is False, will select conflicting objects

    ARGUMENTS:
    obj(string) - the object we'd like to name
    forceOverride(bool)- whether to rename conflicts or not

    RETURNS:
    newName(string) on success
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    ### input check
    assert mc.objExists(obj) is True, "'%s' doesn't exist" %obj
    name = returnUniqueGeneratedName(obj,sceneUnique = sceneUnique)
    nameFactory = NameFactory(obj)
    
    if nameFactory.amIMe(name):
        guiFactory.warning("'%s' is already named correctly."%nameFactory.nameBase)
        return name
    else:
        objLong = mc.ls(obj,long=True)
        renameBuffer = mc.rename(objLong,name)

        shapes = mc.listRelatives(renameBuffer,shapes=True,fullPath=True)
        if shapes:
            for shape in shapes:
                name = returnUniqueGeneratedName(shape,sceneUnique = sceneUnique)
                mc.rename(shape,name)
    
        return renameBuffer
开发者ID:GuidoPollini,项目名称:MuTools,代码行数:33,代码来源:autoname.py

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

示例8: execute

    def execute(self, command):
        from maya import cmds

        parts = command.split()
        if len(parts) > 2:
            raise Exception(
                'Input must be a node type and optional name:\n\n'
                '    multiplyDivide\n'
                '    multiplyDivide myMultiplyDivide\n'
            )

        node_type = parts[0]
        node = None
        name = None
        if len(parts) == 2:
            name = parts[1]

        # Handle dg nodes
        shading_classifications = (
            'Utility', 'Shader', 'Texture', 'Rendering', 'PostProcess', 'Light'
        )
        for cls in shading_classifications:
            if cmds.getClassification(node_type, satisfies=cls.lower()):
                node = cmds.shadingNode(node_type, **{'as' + cls: True})

        # Handle dag nodes
        if not node:
            node = cmds.createNode(node_type)

        if name:
            cmds.rename(node, name)
开发者ID:danbradham,项目名称:hotline,代码行数:31,代码来源:maya.py

示例9: GetGroupName

 def GetGroupName(self):
     #Check to see if the name is saved with the file
     if cmds.objExists("CMSettings"):
         ScenePrepClass.GroupName = cmds.getAttr("CMSettings.ModelName")
         if cmds.objExists(ScenePrepClass.GroupName):
             print "Group name from save"
             return 1
     
     #Check to see if the model is already grouped then use that name#
     if self.SelectedObjectsAreGrouped() != "":
         if cmds.textField("NameTextField",query = True, text = True) != "":
             #Rename the group if a name has been provided
             cmds.rename(ScenePrepClass.GroupName, cmds.textField("NameTextField",query = True, text = True))
             #Replace the name in cursel
             for x in range(len(ScenePrepClass.Cursel)):
                 if ScenePrepClass.Cursel[x] == ScenePrepClass.GroupName:
                     ScenePrepClass.Cursel[x] = cmds.textField("NameTextField",query = True, text = True)
             #
             ScenePrepClass.GroupName = cmds.textField("NameTextField",query = True, text = True)
         print "Group name from model"
         return 1
     
     #otherwise check the textfield
     if cmds.textField("NameTextField",query = True, text = True) != "":
         ScenePrepClass.GroupName = cmds.textField("NameTextField",query = True, text = True)
         print "Group name from field"
     
     if ScenePrepClass.GroupName == "":
         cmds.confirmDialog(m = "Please enter a name for the model")
         return 0
开发者ID:Kif11,项目名称:turbosquid_maya_publisher,代码行数:30,代码来源:ScenePrepFile.py

示例10: create_ik_setup

    def create_ik_setup(self):
        """Creates the IK setup."""
        ik = cmds.ikHandle(sj=self.result_jnts[0], ee=self.result_jnts[-1], sol='ikSplineSolver', ns=1)
        cmds.rename(ik[1], '%s_%s_%s' % (self.side, 'neck', self.nc.effector))
        curve = cmds.rename(ik[2], '%s_%s_%s' % (self.side, 'neck', self.nc.curve))
        cmds.setAttr('%s.inheritsTransform' % curve, 0)
        ik = cmds.rename(ik[0], '%s_%s_%s' % (self.side, 'neck', self.nc.ikhandle))
        cmds.select(self.additional_jnts, curve)
        cmds.skinCluster(tsb=True)
        cmds.parent(ik, self.top_grp)

        cmds.setAttr('%s.dTwistControlEnable' % ik, 1)
        cmds.setAttr('%s.dWorldUpType' % ik, 4)
        cmds.setAttr('%s.dWorldUpAxis' % ik, 4)
        cmds.setAttr('%s.dWorldUpVectorY' % ik, -1)
        cmds.setAttr('%s.dWorldUpVectorEndY' % ik, 1)
        cmds.setAttr('%s.dWorldUpVectorEndZ' % ik, -1)
        cmds.connectAttr('%s.worldMatrix[0]' % self.additional_jnts[0], '%s.dWorldUpMatrix' % ik, f=True)
        cmds.connectAttr('%s.worldMatrix[0]' % self.additional_jnts[1], '%s.dWorldUpMatrixEnd' % ik, f=True)
        self.head_grp = cmds.group(self.controls['head'])
        self.head_grp = cmds.rename(self.head_grp, '%s_head_CTL_%s' % (self.side, self.nc.group))
        cmds.parent(self.head_grp, self.top_grp)
        self.c.move_pivot_to(self.guides['neckEnd'][0], self.guides['neckEnd'][1], self.guides['neckEnd'][2], self.head_grp)
        cmds.parentConstraint(self.controls['head'], self.additional_jnts[-1], mo=True, weight=1)
        cmds.orientConstraint(self.controls['head_rot'], self.result_jnts[-1], mo=True, weight=1)
开发者ID:jonntd,项目名称:Rigganator,代码行数:25,代码来源:dragonneck.py

示例11: creatStereo

def creatStereo():
    camL = mc.ls(sl=1)
    if camL == []:
        mc.confirmDialog(title="Missing", message="Please select a camera!", button=["Ok"])
        return
    cam = camL[0]
    camShape = mc.listRelatives(cam, s=1)[0]
    FL = mc.camera(cam, q=1, fl=1)
    NCP = mc.camera(cam, q=1, ncp=1)
    FCP = mc.camera(cam, q=1, fcp=1)
    cam3d = maya.app.stereo.stereoCameraRig.createStereoCameraRig()
    mc.parent(cam3d[0], cam)
    mc.setAttr(cam3d[0] + ".translate", 0, 0, 0, lock=1)
    mc.setAttr(cam3d[0] + ".rotate", 0, 0, 0, lock=1)
    mc.setAttr(cam3d[0] + ".scale", 1, 1, 1, lock=1)
    cam3dShape = mc.listRelatives(cam3d[0], s=1)[0]
    mc.connectControl("interaxialSleder", stereoShape + ".interaxialSeparation")
    mc.connectControl("zeroSleder", stereoShape + ".zeroParallax")
    mc.setAttr(cam3dShape + ".focalLength", FL)
    mc.setAttr(cam3dShape + ".nearClipPlane", NCP)
    mc.setAttr(cam3dShape + ".farClipPlane", FCP)
    mc.setAttr(cam3dShape + ".zeroParallaxPlane", 1)
    mc.setAttr(cam3dShape + ".safeViewingVolume", 1)
    for i in cam3d:
        mc.rename(i, cam + "_" + i)
    camListStereo = mc.ls(type="stereoRigTransform")
    if camListStereo == []:
        mc.floatSliderGrp(interaxialSleder, e=1, enable=False)
        mc.floatSliderGrp(zeroSleder, e=1, enable=False)
    else:
        stereoShape = mc.listRelatives(camListStereo[0], s=1)[0]
        mc.floatSliderGrp(interaxialSleder, e=1, enable=True)
        mc.floatSliderGrp(zeroSleder, e=1, enable=True)
        mc.connectControl(interaxialSleder, cam3dShape + ".interaxialSeparation")
        mc.connectControl(zeroSleder, cam3dShape + ".zeroParallax")
开发者ID:chuckbruno,项目名称:Python_scripts,代码行数:35,代码来源:stereoPlayblast_new_01.py

示例12: create

def create(baseCrv,curveList,inMeshList,prefix):
	'''
	Create standard copyMeshToCurve setup based on the input arguments
	@param baseCrv: Base curve
	@type baseCrv: str
	@param curveList: List of curves to copy mesh to
	@type curveList: list
	@param inMeshList: List of meshes to copy to curves
	@type inMeshList: list
	@param prefix: Naming prefix
	@type prefix: str
	'''
	# Create copyMeshToCurve node
	copyMeshToCurve = mc.createNode('copyMeshToCurve',n=prefix+'_copyMeshToCurve')
	
	# Connect base curve
	mc.connectAttr(baseCrv+'.worldSpace[0]',copyMeshToCurve+'.baseCurve',f=True)
	
	# Connect input curves
	connectInputCurves(copyMeshToCurve,curveList)
	
	# Connect input mesh
	connectInputMesh(copyMeshToCurve,inMeshList)
	
	# Create output mesh
	outMeshShape = mc.createNode('mesh',n=prefix+'_outMeshShape')
	outMesh = mc.listRelatives(outMeshShape,p=True)[0]
	mc.rename(outMesh,prefix+'_outMesh')
	
	# Connect out mesh
	mc.connectAttr(copyMeshToCurve+'.outputMesh',outMeshShape+'.inMesh',f=True)
	
	# Return Reult
	return copyMeshToCurve
开发者ID:auqeyjf,项目名称:glTools,代码行数:34,代码来源:copyMeshToCurve.py

示例13: ui_on_BTN_create_clicked

    def ui_on_BTN_create_clicked(self, *args):
        cube = m.polyCube(ch=False)[0]

        xPosUI = self.ui_FLTFLDGRP_xPos.getValue()[0]
        xNegUI = self.ui_FLTFLDGRP_xNeg.getValue()[0]
        yPosUI = self.ui_FLTFLDGRP_yPos.getValue()[0]
        yNegUI = self.ui_FLTFLDGRP_yNeg.getValue()[0]
        zPosUI = self.ui_FLTFLDGRP_zPos.getValue()[0]
        zNegUI = self.ui_FLTFLDGRP_zNeg.getValue()[0]

        xPos = max(xPosUI, xNegUI)
        xNeg = min(xPosUI, xNegUI)
        yPos = max(yPosUI, yNegUI)
        yNeg = min(yPosUI, yNegUI)
        zPos = max(zPosUI, zNegUI)
        zNeg = min(zPosUI, zNegUI)

        m.move(xPos, cube + faceMapping['xPos'], worldSpaceDistance=True, x=True)
        m.move(xNeg, cube + faceMapping['xNeg'], worldSpaceDistance=True, x=True)
        m.move(yPos, cube + faceMapping['yPos'], worldSpaceDistance=True, y=True)
        m.move(yNeg, cube + faceMapping['yNeg'], worldSpaceDistance=True, y=True)
        m.move(zPos, cube + faceMapping['zPos'], worldSpaceDistance=True, z=True)
        m.move(zNeg, cube + faceMapping['zNeg'], worldSpaceDistance=True, z=True)

        m.xform(cube, cp=True)
        m.rename(cube, BBOX_NAME)
开发者ID:Italic-,项目名称:maya-prefs,代码行数:26,代码来源:fx_create_aabb.py

示例14: insertDots

    def insertDots(self):

        # copy dot object
        # copy cutout object
        # run mesh difference
        # delete the layers
        # delete the groups
        # rename the cutout.

        for dot in self.dots:
            # Copy sphere object from the template object.
            newDot = cmds.duplicate(self.getTemplateObjectName(dot.templateName()))[0]

            for cutout in dot.cutouts:

                # Copy cutout object from the template object, and rotate it.
                newCutout = cmds.duplicate(self.getTemplateObjectName(cutout.shape))[0]
                cutoutDagPath = self.getDagPathFromPath(newCutout)
                mfnTransform = OpenMaya.MFnTransform(cutoutDagPath)

                mfnTransform.rotateBy(cutout.rotation, OpenMaya.MSpace.kTransform)

                # Mesh boolean combine, with 'difference' operator.
                boolOp = cmds.polyBoolOp(newDot, newCutout, op=2)

                # Update the dot copy name and remove history.
                newDot = boolOp[0]
                cmds.delete(newDot, constructionHistory=True)

            dotPath = "dot_{0}".format(dot.name())
            cmds.rename(newDot, dotPath)

            # Move the new dot onto the final grid for printing.
            self.positionDot(dotPath, dot.vertexId)
开发者ID:rich-nguyen,项目名称:bamboo-workshop,代码行数:34,代码来源:exporter.py

示例15: on_btn_FixSkinBsEnd_clicked

    def on_btn_FixSkinBsEnd_clicked(self, clicked=None):
        if clicked == None:return

        selectIndexes = self.listView_attributeList.selectedIndexes()
        if len(selectIndexes) == 0:return
        selectAttr = self.__AttributeModel.data(selectIndexes[0], QtCore.Qt.DisplayRole)
        if not uiTool.warning('BlendShape\'s shape on attribute "%s" will be changed,\nand it can\'t to undo, \ncontinue? ?'%selectAttr):return

        openCloseDeformer(self.__baseModel, 0, ('skinCluster'))
        newSculpModel = cvShapeInverterCmds.invert(self.__baseModel, self.__sculpmodel, self.progressBar)
        mc.delete(newSculpModel, ch=True)
        openCloseDeformer(self.__baseModel, 1, ('skinCluster'))

        if mc.objExists(selectAttr):
            mc.blendShape(newSculpModel, selectAttr, w=((0, 1)))
            mc.delete(selectAttr, ch=True)
            mc.delete(newSculpModel)
        else:
            shape = mc.listRelatives(newSculpModel, s=True, path=True)[0]

            weightID = self.__AttributeDT2.get(selectAttr, None)
            TGTattr  = self.__IGTAttributeDT.get(weightID, None)
            mc.connectAttr('%s.worldMesh[0]'%shape, '%s.%s'%(self.__blendShape, TGTattr), f=True)

            mc.rename(newSculpModel, selectAttr)
        mc.delete(self.__sculpmodel)
        mc.delete(self.__tempmodel)
开发者ID:zclongpop123,项目名称:MPToolkit,代码行数:27,代码来源:ShapeBuilderUI.py


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