On 18/05/2018 at 12:24, xxxxxxxx wrote:
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
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?
On 21/05/2018 at 02:57, xxxxxxxx wrote:
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
c4d.documents.SaveDocument(...) # Call without passing SAVEDOCUMENTFLAGS_SAVECACHES
# Restore melange cache preferences
On 21/05/2018 at 07:48, xxxxxxxx wrote:
Ahh, I see. Thanks a lot.