def publish(self, settings, item): """ Executes the publish logic for the given item and settings. :param settings: Dictionary of Settings. The keys are strings, matching the keys returned in the settings property. The values are `Setting` instances. :param item: Item to process """ publisher = self.parent # get the path to create and publish publish_path = item.properties["path"] # ensure the publish folder exists: publish_folder = os.path.dirname(publish_path) self.parent.ensure_folder_exists(publish_folder) # Export scene to FBX try: self.logger.info("Exporting scene to FBX {}".format(publish_path)) cmds.FBXResetExport() cmds.FBXExportSmoothingGroups('-v', True) # Mel script equivalent: mel.eval('FBXExport -f "fbx_output_path"') cmds.FBXExport('-f', publish_path) except: self.logger.error("Could not export scene to FBX") return False # The file to publish is the FBX exported to the FBX output path # item.properties["path"] = fbx_output_path # let the base class register the publish super(MayaFBXPublishPlugin, self).publish(settings, item)
def exportSM(self, directory): # This code selects the joints and meshes only. meshes = cmds.ls(selection=True) for x in meshes: if cmds.objectType(x, isType="joint"): print "Nope not SM" else: # Select the mesh and joints to export cmds.select(meshes) smFilePath = directory + self.whichAsset.currentText( ) + "\\" + "Meshes" + "\\" path = self.getPath(smFilePath) sceneName = cmds.file(query=True, sceneName=True, shortName=True) fileName = sceneName.split(".") print smFilePath + str(fileName[0]) + ".fbx" try: cmds.FBXResetExport() cmds.FBXExportShapes("-v", True) # cmds.FBXExportShapes("-q") cmds.FBXExportSmoothingGroups("-v", True) # cmds.FBXExportSmoothingGroups("-q") cmds.FBXExportTangents("-v", True) # cmds.FBXExportTangents("-q") cmds.FBXExportSmoothMesh("-v", True) # cmds.FBXExportSmoothMesh("-q") cmds.FBXExportReferencedAssetsContent("-v", True) # cmds.FBXExportReferencedAssetsContent("-q") # Connections cmds.FBXExportInputConnections("-v", False) # cmds.FBXExportInputConnections("-q") # Axis Conversion cmds.FBXExportUpAxis("y") # cmds.FBXExportUpAxis("-q") cmds.FBXExportFileVersion("-v", "FBX201400") # Export! cmds.FBXExportInAscii("-v", True) cmds.FBXExport("-f", smFilePath + str(fileName[0]) + ".fbx", "-s") except RuntimeError, err: print str(err)
def _maya_export_fbx(self, fbx_output_path): # Export scene to FBX try: self.logger.info("Exporting scene to FBX {}".format(fbx_output_path)) cmds.FBXResetExport() cmds.FBXExportSmoothingGroups('-v', True) # Mel script equivalent: mel.eval('FBXExport -f "fbx_output_path"') cmds.FBXExport('-f', fbx_output_path) except: self.logger.error("Could not export scene to FBX") return False return True
def export_fbx(self, fbx_args): """ Export to FBX given a list of arguments. :param fbx_args: The list of arguments for fbx command to execute :return: True if successful, False otherwise. """ selected_groups = cmds.ls(sl=True) if selected_groups: self.logger.debug('Exporting => {}'.format(selected_groups)) else: self.logger.debug('Exporting all') try: cmds.FBXResetExport() # Extra checkboxes to set prior to export cmds.FBXExportSmoothingGroups('-v', True) cmds.FBXExportTangents('-v', True) cmds.FBXExportSmoothMesh('-v', True) cmds.FBXExportReferencedAssetsContent('-v', True) cmds.FBXExportBakeComplexAnimation('-v', fbx_args[2]) cmds.FBXExportEmbeddedTextures('-v', fbx_args[3]) cmds.FBXExportFileVersion('-v', FBX_EXPORT_VERSION) cmds.FBXExportGenerateLog('-v', False) self.logger.debug('FBX args => {}'.format(fbx_args)) self.logger.debug("cmds.FBXExport('-f', {0}, {1})".format( fbx_args[0], fbx_args[1])) cmds.FBXExport('-f', fbx_args[0], fbx_args[1]) except Exception as e: self.logger.error("Could not export {} to FBX. {}".format( selected_groups, e)) return False return True