Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    1. Maxon Developers Forum
    2. Aeoll 0
    3. Topics
    A
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 3
    • Best 1
    • Controversial 0
    • Groups 0

    Topics created by Aeoll 0

    • A

      c4d.documents.SaveProject() preventing future save commands

      Cinema 4D SDK
      • 2023 python • • Aeoll 0
      2
      0
      Votes
      2
      Posts
      562
      Views

      ferdinandF

      Hello @Aeoll-0,

      Thank you for reaching out to us. You should be a bit more specific about the circumstances and which you are using the command. As declared in our Support Guidelines, you should always post executable code, as we are otherwise are guessing what you are doing.

      The self.filedir implies that this happens in a method, which in turn could mean that you are trying to do this off-main-thread. This is not allowed. I also gave it a spin myself, and for me it works.

      Note that after the operation, the opened file is not the old file anymore. So, when you had a \data\a\myfile.c4d and saved to backup\a\, the opened file will be backup\a\myfile.c4d and not \data\a\myfile.c4d. Because of that, such newly "exported" documents will also induce thumbnail rendering. When you are trying to save many documents at once in this manner, the thumbnail rendering could make Cinema unresponsive. The path into which you want to dump things must also exist, Cinema 4D cannot create it for you.

      I have tested this in 2023.2.2 and 2024.1.0 and found no problems in both versions.

      Cheers,
      Ferdinand

      Result:
      34f18c02-cc1d-42ef-94ac-d50f2ad57195-image.png

      Successfully saved project to: 'e:\projects\foo\', exporting the assets: [{'filename': 'e:\\projects\\foo\\myfile.c4d', 'assetname': 'myfile.c4d', 'channelId': 0, 'netRequestOnDemand': False}, {'filename': 'e:\\projects\\foo\\tex\\Maxon-Computer-Logo.jpg', 'assetname': 'E:\\temp\\Maxon-Computer-Logo.jpg', 'channelId': 0, 'netRequestOnDemand': True}].

      Code:

      import c4d import os doc: c4d.documents.BaseDocument # The active document def main() -> None: """ """ # Cinema 4D cannot create the directory path for us, we must ensure that #path does exist. path: str = "e:\\projects\\foo\\" if not os.path.exists(path): os.makedirs(path) # Your settings. flags: int = (c4d.SAVEPROJECT_ASSETS | c4d.SAVEPROJECT_SCENEFILE | c4d.SAVEPROJECT_USEDOCUMENTNAMEASFILENAME) data: list = [doc, flags, path, [], []] # Invoke the command and raise errors on failure or missing assets. if not c4d.documents.SaveProject(*data): raise IOError(f"Could not save project to: '{path}'.") if data[4]: raise IOError(f"Failed to export the following assets: {data[4]}") # Success :) print (f"Successfully saved project to: '{path}', exporting the assets: {data[3]}.") if __name__ == '__main__': main()
    • A

      Saving Documents

      Cinema 4D SDK
      • python 2023 • • Aeoll 0
      3
      0
      Votes
      3
      Posts
      482
      Views

      A

      Hi Ilia,

      Thanks for the reply - you're correct about what I'm trying to do!

      I've tried your first option and unfortunately the following dialog pops up:

      "Unable to write file $FILE$ (file may be write protected)"

      This dialog does not appear if the file is saved manually with the File -> Save Project As... Dialog

      The save location is a network drive. Let me know if theres a workaround?

      For your second option - is it possible to specify the exact filename here?

      EDIT: It looks like you can also specify a filename here, which has worked - thanks !