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

    Press "Yes" when document is opened?

    Cinema 4D SDK
    r20 python
    2
    5
    650
    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.
    • B
      bentraje
      last edited by bentraje

      Hi,

      I'm trying to open several old documents and save them with the current version.
      The script works but I had to press "Yes" for every document.
      You can see an illustration of the problem here:
      https://www.dropbox.com/s/6ijne28u5unlgej/c4d114_press_yes_python.png?dl=0

      Is there a way around this?

      Thank you for looking at the problem

      You can see the script below

      import c4d
      import os
      
      def main():
      
          for subdir, dirs, files in os.walk('D:\modifyMe'):   
              for file in files:
                  filepath = os.path.join(subdir, file)
                  flags = c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS 
          
                  doc = c4d.documents.LoadDocument(filepath, flags)
                  c4d.documents.InsertBaseDocument(doc)
                  c4d.documents.SetActiveDocument(doc)
                  c4d.CallCommand(12098, 12098) # Save
                  
                  c4d.documents.CloseAllDocuments()
                  
                  c4d.EventAdd()
                  
      
      if __name__=='__main__':
          main()
      
      1 Reply Last reply Reply Quote 0
      • S
        s_bach
        last edited by

        Hello,

        can you provide some old files to reproduce the issue?

        best wishes,
        Sebastian

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 1
        • B
          bentraje
          last edited by

          Hi @s_bach

          Can you check on this one?
          https://www.dropbox.com/s/zcgvmw5fe8m126f/c4d114_press_yes_python_hamster_run.zip?dl=0

          You need to open it in version other than R20 otherwise it won't work.
          Let me know if you need anything else.

          1 Reply Last reply Reply Quote 0
          • S
            s_bach
            last edited by

            Hello,

            The dialog box is not opened when you load the document. The dialog box is opened when you try to save it using CallCommand().

            Using CallCommand() is the exact same as pressing the button in the UI. So there is nothing to prevent that dialog when you use CallCommand().

            But to save the file, you can simply use c4d.documents.SaveDocument(). This should show no pop-up dialog.

            flags = c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST
            c4d.documents.SaveDocument(loadedDoc, finalUpdatedPath, flags, c4d.FORMAT_C4DEXPORT)
            

            Also, it looks like you are creating something similar to the Scene Updater. This plugin is also written in Python, so you might find some inspiration in its source code.

            best wishes,
            Sebastian

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

            1 Reply Last reply Reply Quote 1
            • B
              bentraje
              last edited by

              @s_bach
              RE: The dialog box is not opened when you load the document. The dialog box is opened when you try to save it using CallCommand().

              Thanks for the clarification.
              The code you presented works as expected. Thank you!

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