Example #1
0
 def upload(self, *args):
     print("Uploading")
     self.login()
     #Get File Name
     if self.mw.lineEdit.text() != "":
         print("Saving.")
         dateVar = datetime.datetime.now().strftime(
             "_Autosave_%d%m%Y_%H%M%S")
         fle_nme = str(self.mw.lineEdit.text()) + str(dateVar) + str(
             self.mw.combo_file.currentText())
         fle_path = rootL + "\SaveTemp\\" + fle_nme
         pm.exportAll(fle_path, f=True)
         #Upload Saved File.
         global fld_id
         fld = self.find_folders("Maya2Cloud")
         fld_id = ""
         if fld == []:
             print("Creating Root Folder on GDrive")
             try:
                 new_folder = drive.CreateFile({
                     'title':
                     '{}'.format("Maya2Cloud"),
                     'mimeType':
                     'application/vnd.google-apps.folder'
                 })
                 new_folder.Upload()
             except:
                 print("Unable to create a root Folder")
                 fld2 = find_folders("Maya2Cloud")
                 if fld2 == []:
                     print("Root Folder could not be found.")
                 else:
                     for i in fld2:
                         fld_id = i['id']
         else:
             for i in fld:
                 fld_id = i['id']
         if fld_id == "":
             print("Something went wrong finding a folder")
         else:
             #Upload File to Drive
             upFile = drive.CreateFile({
                 'title':
                 fle_nme,
                 "parents": [{
                     "kind": "drive#fileLink",
                     "id": fld_id
                 }]
             })
             upFile.SetContentFile(fle_path)
             upFile.Upload()
             print("File Uploaded!")
             self.mw.lineEdit.clear()
             upFile.SetContentFile(rootL + "\dummy.txt")
             try:
                 os.remove(fle_path)
             except:
                 print("Coudnt Remove File.")
     else:
         print("Upload Failed.")
Example #2
0
    def save_model(self,
                   model=Model(),
                   icon=True,
                   directory=DEFAULT_DIRECTORY):
        # create model library directory if it doesn't exist...
        self.create_directory(directory)

        # if something is selected, export by selection...
        if pmc.ls(sl=True):
            pmc.exportSelected(model.path, force=1)
        # otherwise export the whole scene...
        else:
            pmc.exportAll(model.path, force=1)

        # generate model icon
        if icon:
            self.create_icon(model)

        # append model to json
        # check if the model already exists in the model_list
        for item in self.model_list:
            if item == model:
                # model is already a member of model_list, do not append...
                return

        # model is not member of model_list, append...
        self.model_list.append(model)

        # update json with new members information...
        with open(JSON_PATH, 'w') as f:
            # TODO: create default method
            json.dump([o.__dict__ for o in self.model_list], f, indent=4)
Example #3
0
 def exportScene(self):
     self.status.setStatus('ExportScene')
     self.status.setStatus('Exporting scene ...')
     self.createScriptNode()
     scenePath = osp.join(self.rootPath, 'scenes', str(self.nameBox.text()))
     pc.exportAll(scenePath,
                  type=cmds.file(q=True, type=True)[0],
                  f=True,
                  pr=True)
     self.status.setStatus('Scene bundled successfully ...')
Example #4
0
 def test_basic_file_cmds(self):
     print "Exporting all", os.path.join( self.temp, 'all.ma' )
     expFile = pm.exportAll( os.path.join( self.temp, 'all.ma' ), preserveReferences=1, force=1)
     print "Importing"
     pm.importFile( expFile )
     print "Exporting all"
     pm.exportAll( os.path.join( self.temp, 'all.ma' ), preserveReferences=1, force=1)
     print "Exporting animation"
     pm.exportAnim( os.path.join( self.temp, 'anim.ma' ), force=1)
     pm.select(pm.SCENE.persp)
     print "Exporting selected animation"
     pm.exportSelectedAnim( os.path.join( self.temp, 'selAnim.ma' ), force=1)
Example #5
0
 def test_basic_file_cmds(self):
     print "Exporting all", os.path.join( self.temp, 'all.ma' )
     expFile = pm.exportAll( os.path.join( self.temp, 'all.ma' ), preserveReferences=1, force=1)
     print "Importing"
     impFile = pm.importFile( expFile )
     print "Exporting all" 
     pm.exportAll( os.path.join( self.temp, 'all.ma' ), preserveReferences=1, force=1)
     print "Exporting animation"
     pm.exportAnim( os.path.join( self.temp, 'anim.ma' ), force=1)
     pm.select(pm.SCENE.persp)
     print "Exporting selected animation"
     pm.exportSelectedAnim( os.path.join( self.temp, 'selAnim.ma' ), force=1)
Example #6
0
 def test_basic_file_cmds(self):
     print "Exporting all", os.path.join( self.temp, 'all.ma' )
     expFile = pm.exportAll( os.path.join( self.temp, 'all.ma' ), preserveReferences=1, force=1)
     print "Importing"
     # if we don't do this newFile first, maya crashes...
     #   BSPR-18231 Maya crashes on import after exporting with references
     pm.newFile(f=1)
     pm.importFile( expFile )
     print "Exporting all"
     pm.exportAll( os.path.join( self.temp, 'all.ma' ), preserveReferences=1, force=1)
     print "Exporting animation"
     pm.exportAnim( os.path.join( self.temp, 'anim.ma' ), force=1)
     pm.select(pm.SCENE.persp)
     print "Exporting selected animation"
     pm.exportSelectedAnim( os.path.join( self.temp, 'selAnim.ma' ), force=1)
Example #7
0
 def test_basic_file_cmds(self):
     print "Exporting all", os.path.join(self.temp, 'all.ma')
     expFile = pm.exportAll(os.path.join(self.temp, 'all.ma'),
                            preserveReferences=1,
                            force=1)
     print "Importing"
     # if we don't do this newFile first, maya crashes...
     #   BSPR-18231 Maya crashes on import after exporting with references
     pm.newFile(f=1)
     pm.importFile(expFile)
     print "Exporting all"
     pm.exportAll(os.path.join(self.temp, 'all.ma'),
                  preserveReferences=1,
                  force=1)
     print "Exporting animation"
     pm.exportAnim(os.path.join(self.temp, 'anim.ma'), force=1)
     pm.select(pm.SCENE.persp)
     print "Exporting selected animation"
     pm.exportSelectedAnim(os.path.join(self.temp, 'selAnim.ma'), force=1)
Example #8
0
def export(filename, filepath, selection=True, pr=True, *args, **kwargs):
    ''' export selection '''
    path = os.path.join(filepath, filename)
    filetype = cmds.file(q=True, typ=True)[0]
    try:
        if selection:

            pc.exportSelected(path,
                              force=True,
                              expressions=True,
                              constructionHistory=True,
                              channels=True,
                              shader=True,
                              constraints=True,
                              options="v=0",
                              typ=filetype,
                              pr=pr)
        else:
            pc.exportAll(path, force=True, typ=filetype, pr=pr)

    except BaseException as e:
        traceback.print_exc()
        print e
        raise BaseException
Example #9
0
	element = cycleAsset.get_element(Department.CYCLES)

	projDir = project.get_project_dir()
	crowdCache = os.path.join(projDir, 'production', 'crowdCache')
	if not os.path.exists(crowdCache):
		os.makedirs(crowdCache)

	cacheFileName = name + '.mb'
	cacheFileName = os.path.join(crowdCache, cacheFileName)
	backupFileDir = os.path.join(os.path.dirname(fileName), 'backup')
	if not os.path.exists(backupFileDir):
		os.makedirs(backupFileDir)
	backupFileName = os.path.join(backupFileDir, os.path.basename(fileName) + '.backup.mb')

	backupResult = pm.exportAll(backupFileName, preserveReferences=True, force=True)
	print 'For your information there is a back up of your file before you did this operation. That file is located here:', backupResult

	#now that we have gotten past all the things that could go wrong we will make a quick grouping to the selection that we don't want the user to know about.
	try:
		pm.group(name=name)
	except:
		millis = byuutil.timestampThisYear()
		name = name + str(millis)
		pm.group(name=name)

	#get the file name for our new asset
	cycleFile = pm.exportSelected(cacheFileName, preserveReferences=True, force=True)
	pm.saveFile() #Make sure we save it so that we will have that group again when we open it.
	print 'opening', cycleFile
	pm.openFile(cycleFile, force=True)
Example #10
0
    def publish(self):
        """
        发布资产到资产库
        assets_name: 资产名字
        assets_code: 资产Code
        top_category: 第一级分类
        sec_category: 第二级分类
        third_category: 第三级分类
        map_resolution: 贴图分辨率
        assets_path: 资产路径
        ma_path: ma文件路径
        mb_path: mb文件路径
        fbx_path: fbx文件路径
        zbrush_path: zbrush文件路径
        sub_paint_path: sunstance paint文件路径
        texture_path: 贴图文件文件路径
        preview_path: 预览图文件路径
        describe: 描述文字
       :return:
        """

        assets_name = self.informationWidget.assetsNameLine.text()
        assets_code = self.informationWidget.assetsCodeLine.text()
        top_category = self.informationWidget.TopCategoryLine.objectName()
        sec_category = self.informationWidget.SecondaryCategoryLine.objectName(
        )
        third_category = self.informationWidget.ThirdCategoryLine.objectName()
        map_resolution = self.informationWidget.MapResolutionCombobox.currentText(
        )
        assets_path = os.path.join(top_category, sec_category, third_category,
                                   assets_name).replace("\\", "/")
        if not third_category:
            assets_path = os.path.join(top_category, sec_category,
                                       assets_name).replace("\\", "/")
        ma_path = "{0}/{1}.ma".format(assets_path, assets_name)
        mb_path = "{0}/{1}.mb".format(assets_path, assets_name)
        fbx_path = "{0}/{1}.fbx".format(assets_path, assets_name)
        zbrush_path = "{0}/{1}.ZTL".format(assets_path, assets_name)
        sub_paint_path = "{0}/{1}.spp".format(assets_path, assets_name)
        texture_path = "{0}/Texture".format(assets_path, assets_name)
        preview_path = "{0}/{1}.jpg".format(assets_path, assets_name)

        describe = self.informationWidget.describeText.toPlainText()

        if not assets_name:
            dy.MMessage.error(u"没有指定资产名称, 请检查 Assets Name", self)
            self.informationWidget.assetsNameLabel.set_dayu_type("danger")
        if not top_category:
            dy.MMessage.error(u"没有指定资产类型, 请检查 Top Category", self)
            self.informationWidget.TopCategoryLabel.set_dayu_type("danger")
        if not sec_category:
            dy.MMessage.error(u"没有指定资产类型, 请检查 Sec Category", self)
            self.informationWidget.SecondaryCategoryLabel.set_dayu_type(
                "danger")

        if not os.path.exists(os.path.join(self.root_path, texture_path)):
            os.makedirs(os.path.join(self.root_path, texture_path))

        self.write_information(
            os.path.join(self.root_path, assets_path,
                         "information.yaml").replace("\\", "/"),
            self.format_information(assets_name, assets_code, top_category,
                                    sec_category, third_category, ma_path,
                                    mb_path, fbx_path, sub_paint_path,
                                    zbrush_path, preview_path, texture_path,
                                    map_resolution, describe))

        self._copy_file(self.preview_path,
                        os.path.join(self.root_path, preview_path))

        self._copy_file(self.sp_path,
                        os.path.join(self.root_path, sub_paint_path))

        self._copy_file(self.zb_path, os.path.join(self.root_path,
                                                   zbrush_path))

        for texture in os.listdir(self.texture_path):
            self._copy_file(
                os.path.join(self.texture_path, texture),
                os.path.join(os.path.join(self.root_path, texture_path),
                             texture))

        if self.informationWidget.maCheckBox.isChecked():
            self.save_maya_file(os.path.join(self.root_path, ma_path))
        if self.informationWidget.mbCheckBox.isChecked():
            self.save_maya_file(os.path.join(self.root_path, mb_path))
        if self.informationWidget.fbxCheckBox.isChecked():
            pm.exportAll(os.path.join(self.root_path, fbx_path),
                         force=True,
                         options="v=0",
                         type="FBX export",
                         pr=True,
                         ea=True)

        dy.MMessage.success(u"上传成功!", self)
Example #11
0
 def _saveAs(self, name, directory):
     pmc.exportAll(os.path.join(directory, name), type='mayaAscii')