Jump to content

ryanjbrant

Limited Member
  • Posts

    1
  • Joined

  • Last visited

Everything posted by ryanjbrant

  1. Hello. I have written a script that allows me to select multiple objects in the C4D object manager and export each individual item as its own unique FBX file. The script works great but has one issue. The resulting FBX file has the correct material applied, but the material path is still looking in the root folder for the texture files. For example: color.png What needs to happen is that these paths need to be relative to the file and embedded. For example: filename.fbm/color.png Is there anyone who could possibly help solve this issue? Please see the python below and attached. I would love any support and would be happy to pay you for your time as this is pretty pressing and causing major delays for me. import c4d, os import c4d.documents as docs from c4d import gui # Main function def main(): # the doc doc = docs.GetActiveDocument() docPath = doc.GetDocumentPath() docName = doc.GetDocumentName() # list-stuff objList = doc.GetSelection() tmpList= [] itemCounter = 0 # Retrieves FBX exporter plugin, 1026370 fbxExportId = 1026370 plug = c4d.plugins.FindPlugin(fbxExportId, c4d.PLUGINTYPE_SCENESAVER) if plug is None: raise RuntimeError("Failed to retrieves the fbx exporter.") data = dict() # Sends MSG_RETRIEVEPRIVATEDATA to fbx export plugin if not plug.Message(c4d.MSG_RETRIEVEPRIVATEDATA, data): raise RuntimeError("Failed to retrieves private data.") # BaseList2D object stored in "imexporter" key hold the settings fbxExport = data.get("imexporter", None) if fbxExport is None: raise RuntimeError("Failed to retrieves BaseContainer private data.") # Set FBX export settings fbxExport[c4d.FBXEXPORT_FBX_VERSION] = c4d.FBX_EXPORTVERSION_NATIVE fbxExport[c4d.FBXEXPORT_ASCII] = False fbxExport[c4d.FBXEXPORT_CAMERAS] = False fbxExport[c4d.FBXEXPORT_LIGHTS] = False fbxExport[c4d.FBXEXPORT_SPLINES] = False fbxExport[c4d.FBXEXPORT_INSTANCES]=False fbxExport[c4d.FBXEXPORT_SELECTION_ONLY]=False fbxExport[c4d.FBXEXPORT_GLOBAL_MATRIX]=True fbxExport[c4d.FBXEXPORT_SDS]=c4d.FBXEXPORT_SDS_BAKED fbxExport[c4d.FBXEXPORT_TRIANGULATE]=False fbxExport[c4d.FBXEXPORT_SAVE_NORMALS]=True fbxExport[c4d.FBXEXPORT_SAVE_VERTEX_COLORS]=False fbxExport[c4d.FBXEXPORT_SAVE_VERTEX_MAPS_AS_COLORS]=False fbxExport[c4d.FBXEXPORT_UP_AXIS]=c4d.FBXEXPORT_UP_AXIS_Y fbxExport[c4d.FBXEXPORT_TRACKS]=False fbxExport[c4d.FBXEXPORT_BAKE_ALL_FRAMES]=True fbxExport[c4d.FBXEXPORT_PLA_TO_VERTEXCACHE]=False fbxExport[c4d.FBXEXPORT_BOUND_JOINTS_ONLY]=False fbxExport[c4d.FBXEXPORT_TAKE_MODE]=c4d.FBXEXPORT_TAKE_NONE fbxExport[c4d.FBXEXPORT_SUBSTANCES]=True fbxExport[c4d.FBXEXPORT_BAKE_MATERIALS]=True fbxExport[c4d.FBXEXPORT_BAKEDTEXTURE_WIDTH]=2048 fbxExport[c4d.FBXEXPORT_BAKEDTEXTURE_HEIGHT]=2048 fbxExport[c4d.FBXEXPORT_BAKEDTEXTURE_FORMAT]=8 fbxExport[c4d.FBXEXPORT_BAKEDTEXTURE_DEPTH]=c4d.FBXEXPORT_BAKEDTEXTURE_DEPTH_8 fbxExport[c4d.FBXEXPORT_MATERIALS]=True fbxExport[c4d.FBXEXPORT_EMBED_TEXTURES]=True fbxExport[c4d.FBXEXPORT_LOD_SUFFIX]=False # check if anything is selected if not objList: gui.MessageDialog('Nothing selected -> nothing saved') else: # create folder, if not present setupFolder = "/Users/ryanbrant/Giant Dropbox/Ryan Brant/Jobs/hmmm/__Asset Library/Assets/Test/Molten-Test/" if not os.path.exists(setupFolder): os.makedirs(setupFolder) # check each obj in selection and save in file after type-check for obj in objList: # check type if not isinstance(obj, c4d.BaseObject): print ("Expected c4d.BaseObject, got %s." % obj.__class__.__name__ + " attached to: "/ + obj.GetObject().GetName()) else: # some list-stuff tmpList.insert(0,obj) # create temp doc and insert selected obj into it theTempDoc = docs.IsolateObjects(doc, tmpList) # save temp doc in folder using the original project-filename & objectname path = str(setupFolder + obj.GetName() + ".fbx") c4d.documents.SaveDocument(theTempDoc, path, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, fbxExportId) # some list-stuff tmpList.remove(obj) # kill temp doc docs.KillDocument(theTempDoc) itemCounter += 1 gui.MessageDialog(str(itemCounter) + ' selected items saved to: ' + setupFolder) # Execute main() if __name__ == '__main__': main() batch-ex-all-individual.py
×
×
  • Create New...

Copyright Core 4D © 2024 Powered by Invision Community