resave C4D file for Melange
-
On 18/05/2018 at 12:24, xxxxxxxx wrote:
Hi,
I am trying just to open C4D file containing some polygonal objects as children of Subdivision surface object and re-save it with for Melange:
... flagsLoad = c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS | c4d.SCENEFILTER_SAVECACHES xDoc = c4d.documents.LoadDocument(xFilePath,flagsLoad) newFileName = destFileName + "-melange.c4d" fpathNew = os.path.join (destPath, newFileName) flagsSave = c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST | c4d.SAVEDOCUMENTFLAGS_SAVECACHES c4d.documents.SaveDocument(xDoc,fpathNew,flagsSave,c4d.FORMAT_C4DEXPORT)
File gets created, but it clearly does not contain any cached data for Melange as file size remains the same, while it should ld be considerably higher because of SDS caching. When I manually open the file, check Save for Melange in Preferences and save the file, file size is indeed much bigger, so there is some problem in the script.
Any idea what can be wrong?
Thanks, Stan
-
On 21/05/2018 at 02:57, xxxxxxxx wrote:
Hi,
There's an issue with SAVEDOCUMENTFLAGS_SAVECACHES.
The workaround is to enable WPREF_SAVE_CACHES and WPREF_SAVE_CACHES_ANIM before calling SaveDocument().
After export is done, restore the cache preferences to their initial state.
Here's some code:bc = c4d.GetWorldContainerInstance() # Retrieve melange cache preferences saveCaches = bc.GetBool(c4d.WPREF_SAVE_CACHES) saveCachesAnim = bc.GetBool(c4d.WPREF_SAVE_CACHES_ANIM) # Enable melange caches preferences bc.SetBool(c4d.WPREF_SAVE_CACHES, True) bc.SetBool(c4d.WPREF_SAVE_CACHES_ANIM, True) c4d.documents.SaveDocument(...) # Call without passing SAVEDOCUMENTFLAGS_SAVECACHES # Restore melange cache preferences bc.SetBool(c4d.WPREF_SAVE_CACHES, saveCaches) bc.SetBool(c4d.WPREF_SAVE_CACHES_ANIM, saveCachesAnim)
-
On 21/05/2018 at 07:48, xxxxxxxx wrote:
Ahh, I see. Thanks a lot.
Stan