Hi @jenandesign sorry for the delay and to not have spotted the issue earlier.
But SaveDocument needs to be called in the main thread. So one solution for you is to send a CoreMessage with c4d.SendCoreMessage to catch it in a MessageData and process it.
import c4d
FBX_EXPORTER_ID = 1026370
FBXEXPORT_TEXTURES = True
FBXEXPORT_EMBED_TEXTURES = False
FBXEXPORT_SAVE_NORMALS = True
FBXEXPORT_ASCII = False
# Main function
def main():
sourcePath = r"C:\Users\graphos\Downloads\fbxtest_v04.c4d"
destinationPath = r"C:\Users\graphos\Documents\test.fbx"
plug = c4d.plugins.FindPlugin(FBX_EXPORTER_ID, c4d.PLUGINTYPE_SCENESAVER)
if plug is None:
logger.appendMessage("FBX Export plugin not found")
return False
op = {}
# Retrieve FBX Eporter settings object
if plug.Message(c4d.MSG_RETRIEVEPRIVATEDATA, op) :
if "imexporter" not in op:
return False
# BaseList2D object stored in "imexporter" key hold the settings
fbxExport = op["imexporter"]
if fbxExport is None :
return False
# Change export settings
#THE FOLLOWING TWO LINES OF CODE WERE ADDED TO FIX SDS OBJECT IMPORT
fbxExport[c4d.FBXEXPORT_SDS_SUBDIVISION] = True
fbxExport[c4d.FBXEXPORT_SDS] = False
fbxExport[c4d.FBXEXPORT_TEXTURES] = FBXEXPORT_TEXTURES
fbxExport[c4d.FBXEXPORT_EMBED_TEXTURES] = FBXEXPORT_EMBED_TEXTURES
fbxExport[c4d.FBXEXPORT_SAVE_NORMALS] = FBXEXPORT_SAVE_NORMALS
fbxExport[c4d.FBXEXPORT_ASCII] = FBXEXPORT_ASCII
doc = c4d.documents.LoadDocument(sourcePath, c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS, None)
status = False
doc.ExecutePasses(None, True, True, True, c4d.BUILDFLAGS_EXPORT)
# Export document to FBX
status = c4d.documents.SaveDocument(doc, destinationPath, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, FBX_EXPORTER_ID)
c4d.documents.KillDocument(doc)
# Retrieve export status and return it
print status
# Execute main()
if __name__=='__main__':
main()
Cheers,
Maxime.