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


Python cmds.file函数代码示例

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


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


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