def ueSaveVers(): if maya.cmds.file(q=True, sn=True) == "": ueSaveAs() return fi = ueMaya.parseFileInfo(maya.cmds.fileInfo(query=True)) spec = ueSpec.Spec(fi["ueproj"], fi["uegrp"], fi["ueasst"], fi["ueclass"], fi["uetype"], fi["uename"]) ueMayaUtils.saveUtility(spec)
def saveUtility(spec, dbMeta={}, fileType="ma", export=False, animated=False): fi = ueMaya.parseFileInfo(maya.cmds.fileInfo(query=True)) e = ueAssetUtils.getElement(spec) if e == {}: e = ueCreate.createElement(spec, dbMeta=dbMeta) v = ueCreate.createVersion(spec, dbMeta=dbMeta) spec.vers = v["version"] maPath = v["path"] maName = v["file_name"] # Load plugins needed for export if fileType == "obj": maya.cmds.loadPlugin("objExport.so") elif fileType == "fbx": maya.cmds.loadPlugin("fbxmaya.so") # Export or save f = os.path.join(maPath, maName+"."+fileType) if export: if fileType == "fbx": maya.mel.eval("FBXExport -s -f \""+f+"\";") else: if animated: start = int(maya.cmds.playbackOptions(query=True, minTime=True)) end = int(maya.cmds.playbackOptions(query=True, maxTime=True)) for i in range(start, end+1): maya.cmds.currentTime(i, edit=True) f = os.path.join(maPath, "%s.%04d.%s" % (maName, i, fileType)) maya.cmds.file(f, exportSelected=True, options=__fileTypes__[fileType][1], type=__fileTypes__[fileType][0]) else: maya.cmds.file(f, exportSelected=True, options=__fileTypes__[fileType][1], type=__fileTypes__[fileType][0]) else: maya.cmds.fileInfo("ueproj", spec.proj) maya.cmds.fileInfo("uegrp", spec.grp) maya.cmds.fileInfo("ueasst", spec.asst) maya.cmds.fileInfo("ueclass", spec.elclass) maya.cmds.fileInfo("uetype", spec.eltype) maya.cmds.fileInfo("uename", spec.elname) maya.cmds.fileInfo("uevers", spec.vers) maya.cmds.fileInfo("version_path", maPath) maya.cmds.file(rename=f) maya.cmds.file(save=True, type=__fileTypes__[fileType][0]) # if "thumbnail" in p: # source = os.path.join(os.getenv("ASST_ROOT"), "tmp", "ueSaveThumbs_"+str(p["thumbnail"])+".png") # dest = ueAssetUtils.getThumbnailPath(spec) # if not os.path.exists(os.path.dirname(dest)): # ueFileUtils.createDir(os.path.dirname(dest)) # ueFileUtils.moveFile(source, dest) print "Saved %s" % spec
def saveUtility(spec, dbMeta={}, fileType="ma", export=False, animated=False): fi = ueMaya.parseFileInfo(maya.cmds.fileInfo(query=True)) e = ueAssetUtils.getElement(spec) if e == {}: e = ueCreate.createElement(spec, dbMeta=dbMeta) v = ueCreate.createVersion(spec, dbMeta=dbMeta) spec.vers = v["version"] maPath = v["path"] maName = v["file_name"] # Load plugins needed for export if fileType == "obj": maya.cmds.loadPlugin("objExport.so") elif fileType == "fbx": maya.cmds.loadPlugin("fbxmaya.so") # Export or save f = os.path.join(maPath, maName + "." + fileType) if export: if fileType == "fbx": maya.mel.eval("FBXExport -s -f \"" + f + "\";") else: if animated: start = int(maya.cmds.playbackOptions(query=True, minTime=True)) end = int(maya.cmds.playbackOptions(query=True, maxTime=True)) for i in range(start, end + 1): maya.cmds.currentTime(i, edit=True) f = os.path.join(maPath, "%s.%04d.%s" % (maName, i, fileType)) maya.cmds.file(f, exportSelected=True, options=__fileTypes__[fileType][1], type=__fileTypes__[fileType][0]) else: maya.cmds.file(f, exportSelected=True, options=__fileTypes__[fileType][1], type=__fileTypes__[fileType][0]) else: maya.cmds.fileInfo("ueproj", spec.proj) maya.cmds.fileInfo("uegrp", spec.grp) maya.cmds.fileInfo("ueasst", spec.asst) maya.cmds.fileInfo("ueclass", spec.elclass) maya.cmds.fileInfo("uetype", spec.eltype) maya.cmds.fileInfo("uename", spec.elname) maya.cmds.fileInfo("uevers", spec.vers) maya.cmds.fileInfo("version_path", maPath) maya.cmds.file(rename=f) maya.cmds.file(save=True, type=__fileTypes__[fileType][0]) # if "thumbnail" in p: # source = os.path.join(os.getenv("ASST_ROOT"), "tmp", "ueSaveThumbs_"+str(p["thumbnail"])+".png") # dest = ueAssetUtils.getThumbnailPath(spec) # if not os.path.exists(os.path.dirname(dest)): # ueFileUtils.createDir(os.path.dirname(dest)) # ueFileUtils.moveFile(source, dest) print "Saved %s" % spec
def export(self): destSpec, dbMeta = ueCommonSave.getValues() fi = ueMaya.parseFileInfo(maya.cmds.fileInfo(query=True)) sourceSpec = ueSpec.Spec(fi["ueproj"], fi["uegrp"], fi["ueasst"], fi["ueclass"], fi["uetype"], fi["uename"], fi["uevers"]) dbMeta["comment"] = "Exported from %s" % str(sourceSpec) # Get the selected nodes from the dialog list selection = [] for i in self.itemMenu.selectedItems(): selection.append(str(i.text())) # If we're exporting all our seleted items into one element, # add the entire list into another list so when we iterate over # it, we return the list once and export everything if not self.exportAsSeparateElements.isChecked(): newSelection = [] newSelection.append(selection) selection = newSelection # Iterate over our selection and export if destSpec.elclass == "ms": for item in selection: if self.exportAsSeparateElements.isChecked(): destSpec.elname = item.replace(":", "") maya.cmds.select(item, r=True) ueMayaUtils.saveUtility(destSpec, dbMeta=dbMeta, fileType="ma", export=True) elif destSpec.elclass == "cam": for item in selection: if self.exportAsSeparateElements.isChecked(): destSpec.elname = item.replace(":", "") maya.cmds.select(item, r=True) destSpec.elclass = "ms" ueMayaUtils.saveUtility(destSpec, dbMeta=dbMeta, fileType="ma", export=True) if self.exportCache.isChecked(): destSpec.elclass = "cam" ueMayaUtils.saveUtility(destSpec, dbMeta=dbMeta, fileType="fbx", export=True) elif destSpec.elclass == "lgt": for item in selection: if self.exportAsSeparateElements.isChecked(): destSpec.elname = item.replace(":", "") maya.cmds.select(item, r=True) destSpec.elclass = "ms" ueMayaUtils.saveUtility(destSpec, dbMeta=dbMeta, fileType="ma", export=True) if self.exportCache.isChecked(): destSpec.elclass = "lgt" ueMayaUtils.saveUtility(destSpec, dbMeta=dbMeta, fileType="fbx", export=True) elif destSpec.elclass == "geo": for item in selection: if self.exportAsSeparateElements.isChecked(): destSpec.elname = item.replace(":", "") maya.cmds.select(item, r=True) destSpec.elclass = "ms" ueMayaUtils.saveUtility(destSpec, dbMeta=dbMeta, fileType="ma", export=True) if self.exportCache.isChecked(): destSpec.elclass = "geo" ueMayaUtils.saveUtility(destSpec, dbMeta=dbMeta, fileType="obj", export=True) elif destSpec.elclass == "mrs": for item in selection: if self.exportAsSeparateElements.isChecked(): destSpec.elname = item.replace(":", "") maya.cmds.select(item, r=True) ueMayaUtils.saveUtility(destSpec, dbMeta=dbMeta, fileType="ma", export=True) # ueFileUtils.deleteFiles(os.path.join(os.path.join(os.getenv("ASST_ROOT"), "tmp", "ueSaveThumbs_*.png"))) self.close()