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

Python cmds.file函数代码示例

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

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



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

示例1: exportL2F

def exportL2F():#EXPORT RL 2 FILES
	#list ON LAYERS
	onlayers=[] 
	for each in getSceneData()['layers']:
		if mc.getAttr(str(each)+'.renderable'):
			if not ':' in each:
				onlayers.append(each)       
	fileNames=[]
	for each in l2fOutputFiles():
		fileNames.append(l2fOutputFolder()+each)
		
	#PROCEDURE
	if mc.getAttr('renderLayerManager.enableSingleFileName')==True:#IF SINGLE FILE OPTION 
		try:
			mc.file(os.path.normpath(fileNames[0]),ea=1,typ='mayaBinary')
		finally:
			print 'OUTPUT FILE:\n'+ os.path.normpath(fileNames[0])
	else:#MULTI FILE OPTION
		progress=1/len(onlayers)
		for each in onlayers: mc.setAttr(str(each)+'.renderable',0) #TURN OFF ON
		#MULTIPLE EXPORT
		mc.progressWindow(t='Saving..',min=0,max=len(onlayers),pr=progress,st='Copying\n'+onlayers[0])
		try:
			for index,each in enumerate(onlayers): #SEQUENTIALLY TURN ON, EXPORT, THEN TURN OFF
				mc.setAttr(str(each)+'.renderable',1)
				mc.file(os.path.normpath(fileNames[index]),ea=1,typ='mayaBinary')
				print 'OUTPUT FILE:'+ os.path.normpath(os.path.join(l2fOutputFolder()+each+'.mb'))
				progress=progress+1
				mc.progressWindow(e=1,pr=progress,st='Save Success \n'+ each)  
				mc.setAttr(str(each)+'.renderable',0)
		finally: mc.progressWindow(ep=1)        
		for each in onlayers: mc.setAttr(str(each)+'.renderable',1)#TURN BACK ON ONLAYERS
开发者ID:RobRuckus,项目名称:rcTools,代码行数:32,代码来源:rcFileManager.py


示例2: purge_data

def purge_data(arg=None):
    """Purge all data. Tag scene as modified."""
    log.debug("Purging global data...")
    pmc.fileInfo("CMan_data", "")
    _CMan.clear_list()
    cmds.file(modified=True)
    log.warning("Purge complete")
开发者ID:Italic-,项目名称:maya-scripts,代码行数:7,代码来源:__init__.py


示例3: publish

	def publish(self, makePreview = False, tags = '', notes = '' ):
		"""export shader to library"""
		shad = mn.Node( self.name )
		mc.select( shad.shader, ne = True )
		exportPath = self.path + self.name + '.ma'
		if self.published: #Make a bakup
			self.saveVersion()
			print 'make a fucking backup!'
		else:
			os.makedirs( self.path )
		self._savedata( tags, notes, None )
		n = mn.Node( self.name )
		"""
		if not n.a.id.exists:
			n.a.id.add()
			print self.id
			n.a.id.v = self.id
		if not n.a.category.exists:
			n.a.category.add()
			n.a.category = self.category
		if not n.a.path.exists:
			n.a.path.add()
			n.a.path.v = exportPath
		"""
		mc.file( exportPath , force = True, options = "v=0", typ = "mayaAscii", pr = True, es = True )
		self.settexturespath( self.path + 'Textures/', exportPath )
		previewtime = 0
		if makePreview:
			print 'creating preview'
			previewtime = self.preview()
开发者ID:skarone,项目名称:PipeL,代码行数:30,代码来源:shaderLibrary.py


示例4: execute

    def execute(my):

        # get the sobject passed in
        sobject = my.get_input_value('sobject')
        code = sobject.get('code')
        search_key = my.get_package_value("search_key")

        # get the designated local directory to put temporary files
        tmp_dir = my.get_package_value("local_dir")
        path = "%s/%s.ma" % (tmp_dir, code)

        context = my.get_package_value("asset_context")
        # FIXME: ignore subcontext for now
        #subcontext = my.get_package_value("asset_sub_context")
        #if subcontext:
        #    context = "%s/%s" % (context, subcontext)

        # save out the file
        cmds.file( rename=path)
        cmds.file( save=True, type='mayaAscii')

        # checkin the file that was just saved
        my.server.upload_file(path)
        snapshot = my.server.simple_checkin(search_key, context, path)

        # add a mock dependency
        snapshot_code = snapshot.get("code")
        my.server.add_dependency(snapshot_code, "C:/tt.pdf")
开发者ID:2gDigitalPost,项目名称:tactic_src,代码行数:28,代码来源:examples.py


示例5: __init__

    def __init__(self, parent=getMayaWindow()):
        super(BasicDialog, self).__init__(parent)

        self.sceneDirectory=(cmds.file(q=1, sn=1)).rsplit('/', 1)[0]
        self.mayaScene=(cmds.file(q=1, sn=1)).rsplit('/', 1)[-1]
        
        self.setWindowTitle("lightSnapshot")
        self.shapeTypeCB=QtGui.QComboBox(parent=self)
        #self.populateCB()
       
        #createWidgets
        self.timelbl=QtGui.QLabel("description", parent=self)                 
        self.scenelbl=QtGui.QLabel("scene", parent=self)
        self.loadBtn=QtGui.QPushButton("Load")
        self.saveBtn=QtGui.QPushButton("Save")

        #Layout Widgets
        actionLayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self)
        actionLayout.addWidget(self.shapeTypeCB)

        actionLayout.addWidget(self.timelbl)
        actionLayout.addWidget(self.scenelbl)
        actionLayout.addWidget(self.loadBtn)          
        actionLayout.addWidget(self.saveBtn)
        
        self.populateCB()
        self.changeLabels()
          
        #Connecting Signals
        self.connect(self.shapeTypeCB, QtCore.SIGNAL("currentIndexChanged(int)"), self.changeLabels)           
        self.connect(self.saveBtn, QtCore.SIGNAL("clicked()"), self.saveButton)
        self.connect(self.loadBtn, QtCore.SIGNAL("clicked()"), self.loadAttr)
开发者ID:spedmonkey,项目名称:lightSnapshot,代码行数:32,代码来源:lightSnapshot.py


示例6: open_scene

def open_scene(file_path, dir_path, all_process):
    # check if scene need saving
    new_scene = mel.eval('saveChanges("file -f -new")')
    if new_scene:
        # print('Opening: ' + file_path)
        set_workspace(dir_path, all_process)
        cmds.file(file_path, o=True)
开发者ID:heylenz,项目名称:TACTIC-Handler,代码行数:7,代码来源:maya_functions.py


示例7: referenceHeroPages

def referenceHeroPages():
	mc.file(
		"X:/Projects/GREY11_ANM71_Rewe_Starzone/GR11A71_Shots/GR11A71_Animatic/Animatic_Maya/scenes/05_Rigging/GR11A71_heroPages_Rigging_v002_tR.mb",
		reference=1,
		r=True,
		namespace="hp"
		)
开发者ID:maitelels,项目名称:maya_scripts,代码行数:7,代码来源:tim_pageSetupReferenceHeroPages.py


示例8: _do_maya_post_publish

    def _do_maya_post_publish(self, work_template, progress_cb):
        """
        Do any Maya post-publish work

        :param work_template:   The primary work template used for the publish
        :param progress_cb:     Callback to be used when reporting progress
        """        
        import maya.cmds as cmds
        
        progress_cb(0, "Versioning up the scene file")
        
        # get the current scene path:
        scene_path = os.path.abspath(cmds.file(query=True, sn=True))
        
        # increment version and construct new file name:
        progress_cb(25, "Finding next version number")
        fields = work_template.get_fields(scene_path)
        next_version = self._get_next_work_file_version(work_template, fields)
        fields["version"] = next_version 
        new_scene_path = work_template.apply_fields(fields)
        
        # log info
        self.parent.log_debug("Version up work file %s --> %s..." % (scene_path, new_scene_path))
        
        # rename and save the file
        progress_cb(50, "Saving the scene file")
#         cmds.file(rename=new_scene_path)
        cmds.file(save=True)
        
        progress_cb(100)
开发者ID:LSpipe,项目名称:TESTING123_sandbox,代码行数:30,代码来源:post_publish.py


示例9: setup

 def setup(self):
     cmds.file(new=True,f=True)
     r9Meta.MetaClass(name='MetaClass_Test')
     r9Meta.MetaRig(name='MetaRig_Test')
     r9Meta.MetaRigSupport(name='MetaRigSupport_Test')
     r9Meta.MetaFacialRig(name='MetaFacialRig_Test')
     r9Meta.MetaFacialRigSupport(name='MetaFacialRigSupport_Test')
开发者ID:vitattoo,项目名称:Red9_StudioPack,代码行数:7,代码来源:Red9_MetaTests.py


示例10: testExportWithKindAttrAndKindFlag

    def testExportWithKindAttrAndKindFlag(self):
        """
        Tests exporting a Maya file with both USD_kind custom attributes and
        using the usdExport -kind flag; there should be an error if the USD_kind
        is not derived from the kind specified in the -kind flag.
        """
        cmds.file(os.path.abspath('KindTestUsdKindAttr.ma'), open=True, force=True)
        cmds.loadPlugin('pxrUsd')

        usdFilePath = os.path.abspath('KindTestUsdKindAttr.usda')
        with self.assertRaises(RuntimeError):
            cmds.usdExport(mergeTransformAndShape=True,
                           file=usdFilePath,
                           kind='assembly')

        cmds.usdExport(mergeTransformAndShape=True,
            file=usdFilePath,
            kind='model')
        stage = Usd.Stage.Open(usdFilePath)
        self.assertTrue(stage)

        rootPrim = stage.GetPrimAtPath('/KindTest')
        self.assertTrue(Kind.Registry().IsA(Usd.ModelAPI(rootPrim).GetKind(),
                'component'))
        rootPrim2 = stage.GetPrimAtPath('/KindTest2')
        self.assertTrue(Kind.Registry().IsA(Usd.ModelAPI(rootPrim2).GetKind(),
                'assembly'))
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:27,代码来源:testUsdMayaModelKindProcessor.py


示例11: importCloth

def importCloth(filePath):
    try:
        spaceName = ''
        spaceName = filePath.rsplit('/', 1 )[1].split('.')[0]
        cmds.file ( filePath, i=1, type='mayaAscii', ra=True, namespace=spaceName, options='v=0', pr=1, loadReferenceDepth='all' )
    except:
        pass
开发者ID:chuckbruno,项目名称:Python_scripts,代码行数:7,代码来源:PoseMangers_03.py


示例12: testExportWithKindFlag

    def testExportWithKindFlag(self):
        """
        Tests exporting a Maya file with no USD_kind custom attributes
        and using the usdExport -kind flag.
        """
        cmds.file(os.path.abspath('KindTest.ma'), open=True, force=True)
        cmds.loadPlugin('pxrUsd')

        usdFilePath = os.path.abspath('KindTest.usda')

        # Check the error mark; this ensures that we actually got a Tf error
        # (that was eventually converted into a Maya error, which Maya raises
        # in Python as a RuntimeError).
        mark = Tf.Error.Mark()
        mark.SetMark()
        with self.assertRaises(RuntimeError):
            cmds.usdExport(mergeTransformAndShape=True,
                           file=usdFilePath,
                           kind='assembly')
        errors = mark.GetErrors()
        self.assertEqual(len(errors), 1)
        self.assertIn(
            "</KindTest> has kind 'assembly', which is derived from 'assembly'",
            str(errors[0]))

        cmds.usdExport(mergeTransformAndShape=True,
            file=usdFilePath,
            kind='fakeKind')
        stage = Usd.Stage.Open(usdFilePath)
        self.assertTrue(stage)

        rootPrim = stage.GetPrimAtPath('/KindTest')
        self.assertTrue(Kind.Registry().IsA(Usd.ModelAPI(rootPrim).GetKind(),
                'fakeKind'))
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:34,代码来源:testUsdMayaModelKindProcessor.py


示例13: testExportWithAssemblyAndMesh

    def testExportWithAssemblyAndMesh(self):
        """
        Tests exporting a Maya file with a root prim containing an assembly
        and a mesh.
        """
        cmds.file(os.path.abspath('KindTestAssemblyAndMesh.ma'), open=True,
                force=True)
        cmds.loadPlugin('pxrUsd')

        # Should fail due to the mesh.
        usdFilePath = os.path.abspath('KindTestAssemblyAndMesh.usda')
        with self.assertRaises(RuntimeError):
            cmds.usdExport(mergeTransformAndShape=True,
                           file=usdFilePath,
                           kind='assembly')

        # Should be 'component' because of the mesh
        usdFilePath = os.path.abspath('KindTestAssemblyAndMesh.usda')
        cmds.usdExport(mergeTransformAndShape=True,
            file=usdFilePath)
        stage = Usd.Stage.Open(usdFilePath)
        self.assertTrue(stage)

        rootPrim = stage.GetPrimAtPath('/KindTest')
        self.assertTrue(Kind.Registry().IsA(Usd.ModelAPI(rootPrim).GetKind(),
                'component'))
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:26,代码来源:testUsdMayaModelKindProcessor.py


示例14: openSelectedCallback

        def openSelectedCallback(self,*args):
                """
                This method is called on double click selected item in textscrollList
                """
                #try block also saves from error caused by directories that we do not have rights to access.
                cMsg="Selected scene file is already open. Do you want to reload it?\n If you reload all changes you made since last save will be lost."
                try:
                        cmds.button('upBtn',edit=True,enable=True)
                        self.selectedItem=str(os.path.join(cmds.textField('location',q=True,tx=True),str(cmds.textScrollList('fileLister',q=True,si=True)[0]).split(" > ")[0])).replace("/","\\")

                        if (self.selectedItem.endswith("ma")) or (self.selectedItem.endswith("mb")):
                                print "selected Item: %s\n scene Open: %s"%(self.selectedItem , cmds.file(q=True,sn=True))
                                if self.selectedItem==cmds.file(q=True,sn=True).replace("/","\\"):
                                        print "Same Scene"
                                        result=cmds.confirmDialog(t='Warning',m=cMsg,button=['Yes','No'], defaultButton='Yes', cancelButton='No', dismissString='No' )
                                        if result== "Yes":
                                                state= cmds.file(self.selectedItem,open=True, f=True)
                                else:
                                        print"Saved scene file %s"%os.path.basename(cmds.file(q=True,sn=True))
##                      if not cmds.file(q=True,save=True):
##                         cmds.file(save=True)
                                        state= cmds.file(self.selectedItem,open=True, f=True)
                        else:
                                if os.path.isdir(self.selectedItem):
                                        cmds.textField('location',edit=True,tx=self.selectedItem)
                                        self.populatescrollList(self.selectedItem.replace("/","\\"))

                except Exception as e:
                        print e
开发者ID:sanfx,项目名称:pythonScripts,代码行数:29,代码来源:minime.py


示例15: presetSave

    def presetSave(self):
        currentSelection = cmds.ls(sl=True)
        newPresetName = self.presetName.text()

        if not newPresetName == "":
            print self.allElements.isChecked()
            if self.allElements.isChecked():
                elementsToSave = self.getVrayElements()
            else:
                elementsToSave = mel.eval("treeView -query -selectItem listAdded")

            if elementsToSave:
                cmds.select(elementsToSave)
                print "saving %s " % elementsToSave
                cmds.file("%s%s" % (presetPath, newPresetName), force=True, options="v=0", type="mayaBinary", pr=True, es=True)
                self.findPresets()

            self.presetName.clear()

            if currentSelection:
                cmds.select(currentSelection)
            else:
                cmds.select(d=True)
        else:
            print "please give the preset a name before saving"
开发者ID:davidwilliamsDK,项目名称:maya,代码行数:25,代码来源:dsVrayElementsTool.py


示例16: create_module

	def create_module(self, moduleType):
		# new module dialog
		moduleName, ok = QtGui.QInputDialog().getText(self, 'Add ' + moduleType + ' Module', 'Enter module name:', QtGui.QLineEdit.Normal, moduleType)

		if ok and moduleName != "":

			# If module with name is exist
			if cmds.objExists(moduleName+":main"):
				QtGui.QMessageBox.information(self, "Warning", "This module is exist.")
			else:
				# add module to list
				item = QtGui.QListWidgetItem(moduleName)
				self.modules_listWidget.addItem(item)
				self.modules_listWidget.setCurrentItem(item)
				
				# import module  
				cmds.file("G:/Projects New/AnimaCord/pk_rig/%s/%s_rig.mb" %(moduleType,moduleType), r=True, type="mayaBinary", namespace=moduleName)
				cmds.file("G:/Projects New/AnimaCord/pk_rig/%s/%s_rig.mb" %(moduleType,moduleType), importReference=True )
				cmds.parent(moduleName+":main", characterRoot)
				
				# set module name
				cmds.setAttr(moduleName+":main.moduleName", moduleName, type="string")
				
				cmds.hide(moduleName+":controls")
				cmds.select(moduleName+":main_poser")
				
				self.update_modules_list()
开发者ID:PavelCrow,项目名称:pkRig,代码行数:27,代码来源:pk_rig_window.py


示例17: publish

def publish():
	# Import Modules
	import shutil

	# Get SceneName and Root
	fullName = cmds.file(sceneName=True, q=True)
	paths = fullName.split("/")

	taskName = paths[-2].split("_")[2]
	assetCode = paths[-2].split("_")[1]
	assetName = Assets.getFullName(assetCode)

	outFolder =  "/".join(paths[:-1]) + "/" + assetCode + "_" + taskName + "_OUT"
	outName = assetName + "_" + taskName

	cmds.file( save=True, type='mayaAscii' )					# Save File
	shutil.copy2(fullName, outFolder + "/" + outName + ".ma")	# Copy File to MASTER
	cmds.warning("[Kroentlied Pipeline] Published !")

	# Copy File to BackUp
	oldFolder = outFolder + "/" + assetCode + "_" + taskName + "_OUT_OLD"
	backup = VersionControl.getLatest(oldFolder, 1)

	if not backup:	# No Backup found yet
	    backup = outName + "_BackUp_v001.ma"

	shutil.copy2(fullName, oldFolder + "/" + backup)
	print "[Kroentlied Pipeline] PublishBackup: " + backup
	return
开发者ID:Loqy,项目名称:Kroetenlied_Pipeline,代码行数:29,代码来源:mayaCommands.py


示例18: addCharacter

    def addCharacter(self, close, *args):
        project = cmds.optionMenu(self.widgets["project"], q=True, value=True)
        selectedCharacter = cmds.textScrollList(self.widgets["characterList"], q=True, si=True)[0]
        rigPath = os.path.join(
            self.mayaToolsDir, "General", "ART", "Projects", project, "AnimRigs", selectedCharacter + ".mb"
        )
        # find existing namespaces in scene
        namespaces = cmds.namespaceInfo(listOnlyNamespaces=True)
        # reference the rig file
        cmds.file(
            rigPath, r=True, type="mayaBinary", loadReferenceDepth="all", namespace=selectedCharacter, options="v=0"
        )
        # clear selection and fit view
        cmds.select(clear=True)
        cmds.viewFit()
        panels = cmds.getPanel(type="modelPanel")
        # turn on smooth shading
        for panel in panels:
            editor = cmds.modelPanel(panel, q=True, modelEditor=True)
            cmds.modelEditor(editor, edit=True, displayAppearance="smoothShaded", displayTextures=True, textures=True)
        # find new namespaces in scene (this is here in case I need to do something later and I need the new name that was created)
        newCharacterName = selectedCharacter
        newNamespaces = cmds.namespaceInfo(listOnlyNamespaces=True)
        for name in newNamespaces:
            if name not in namespaces:
                newCharacterName = name
        # launch UI
        import ART_animationUI

        reload(ART_animationUI)
        ART_animationUI.AnimationUI()
        if close:
            cmds.deleteUI(self.widgets["window"])
开发者ID:Slugnifacent,项目名称:UnrealEngine,代码行数:33,代码来源:ART_addCharacter_UI.py


示例19: saveToNW

	def saveToNW(self, *pArgs):
		self.nameOfCurr = self.getNameOfFile()
		self.filepathnew = os.path.dirname(self.nameOfCurr)
		versionslocal = []
		matchObj = re.match( r'.*\\(.+)\..+', self.nameOfCurr, re.M|re.I)
		if matchObj:
			substringForName=matchObj.group(1)[:-5]
		for f in os.listdir(self.filepathnew):
			if substringForName in f:
				addThis = f[-6:-3]
				versionslocal.append(addThis)
		#getting the number part of the string and adding that to versionList
		versionslocal = sorted(versionslocal)
		theversionToOpen = versionslocal[len(versionslocal)-1]
		temp = str((int(theversionToOpen)+1)).zfill(3)
		#incrementing version number and then converting back to a string
		subs = self.nameOfCurr.replace(self.nameOfCurr[-6:-3], temp)
		cmds.file(rename = subs)
		cmds.file(save = True)
		de=cmds.optionMenu( "deptList", query = True, value = True)
		sc=cmds.optionMenu( "sceneList", query = True, value = True)
		print dept, scene
		self.comboChBgLoad(dept, scene)
		#to reload all other combo boxes according to the new information
		self.makeSaveVisible()
开发者ID:sid2364,项目名称:Maya_Python,代码行数:25,代码来源:ShotManager_PlugIn__Sid.py


示例20: export_hierarchy_obj

    def export_hierarchy_obj(self):
        """Export the individual meshes in the hierarchy"""
        file_info = {}
        # Reverse the geo list so that the deepest geo is deleted first in case there is a geo inside geo
        geo_list = self.geo_list
        geo_list.reverse()
        for self.current_target in geo_list:
            pm.delete(self.current_target, ch=1)
            parent = pm.listRelatives(self.current_target, parent=True)
            pm.parent(self.current_target, w=True)
            pm.select(self.current_target)
            path = libFile.linux_path(libFile.join(self.export_dir, self.current_target + ".obj"))
            # Load the obj plugin
            cmds.file(path,
                      pr=1,
                      typ="OBJexport",
                      force=1,
                      options="groups=0;ptgroups=0;materials=0;smoothing=0;normals=0",
                      es=1)
            file_info[self.current_target] = path
            logger.info("Exporting\n%s" % file_info[self.current_target])
            if not self.new_scene and self.cleansing_mode:
                pm.delete(self.current_target)
                pm.refresh()
            else:
                pm.parent(self.current_target, parent)

            self.update_progress()

        # Write the geo file_info
        self.geo_file_info = file_info
开发者ID:pritishd,项目名称:PKD_Tools,代码行数:31,代码来源:libGeo.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python cmds.fileDialog函数代码示例发布时间:2022-05-27
下一篇:
Python cmds.expression函数代码示例发布时间: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