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
    • Recent
    • Tags
    • Users
    • Login

    Saving the ACTIVE File

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 316 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 28/03/2013 at 02:12, xxxxxxxx wrote:

      Hey guys,

      I'm trying to save the ACTIVE scene, not a copy of it with the following code:

        
        
      _<_t_>_
          
          
                  doc = c4d.documents.GetActiveDocument()  
            
                if doc.GetDocumentPath() == "":  
                    filePath = doc.GetDocumentPath()  
                    if c4d.documents.SaveDocument(doc, doc.GetDocumentName(), saveflags = c4d.SAVEDOCUMENTFLAGS_SAVEAS, format = c4d.FORMAT_C4DEXPORT) == False:  
                        print "File not saved"  
                        Message = c4d.BaseContainer()  
                        Message.SetString(0, "blabla")  
                        result = gui.ShowPopupDialog(cd = None, bc = Message, x=700, y=700)  
                        print result  
                        return True  
            
                 ...  
                 ...  
                 ...  
          
      <_<_t_>_
      

      It saves the document allright, but it saves a copy of it, not the actual file i'm working on. For example, If i save it in the "Save As..." Popup as PluginTest.c4d, it's being saved as that, but the file i'm working on is still called untitled 1.c4d, and if I execute the plugin again,
      doc.GetDocumentPath() == ""
      still returns true, hence it was not really saved.

      Does anyone know what to do about it?

      Thanks in advance

      Aurel

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

        On 28/03/2013 at 07:23, xxxxxxxx wrote:

        I'm not a big fan of using CallCommands because the built-in undos are such a hassle to deal with.
        But in this case. I think it's something you can probably get away with using.

          
          c4d.CallCommand(12098)      #Saves the active document  
        

        -ScottA

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

          On 28/03/2013 at 07:48, xxxxxxxx wrote:

          BaseDocument.GetName() will always be an empty string for unsaved documents. most os
          do not like empty strings as file names.

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

            On 29/03/2013 at 03:25, xxxxxxxx wrote:

            Thanks guys!

            Will try that 😉

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