Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    resave C4D file for Melange

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 1.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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)
        
        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 21/05/2018 at 07:48, xxxxxxxx wrote:

          Ahh, I see. Thanks a lot.

          Stan

          1 Reply Last reply Reply Quote 0
          • First post
            Last post