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

    Save all Objects on a Layer then delete from doc

    PYTHON Development
    0
    5
    517
    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
      Helper
      last edited by

      On 25/06/2015 at 06:54, xxxxxxxx wrote:

      Hi

      I want to save all objects to a seperate file which are on a certain layer.

      original_document.c4d
      Layer: Small_Stuff
      -> select objects from layer
      -> save selected objects in seperate file called "original_document_Small_Stuff.c4d"
      -> delete all objects from original_document.c4d (active)

      would be nice if no dialog opens and the new document rests besides the org document.

      I researched a bit and found this but as always the sdk confuses me more than it helps
      https://developers.maxon.net/docs/py/2023_2//help/modules/c4d.plugins/BaseData/NodeData/SceneSaverData/index.html#SceneSaverData.Save

      thanks in advance.
      mogh

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

        On 25/06/2015 at 08:30, xxxxxxxx wrote:

        got it

        code without defs

        the important stuff is within else:

          
            doc = GetActiveDocument()   
            layer_not_hit = layer_init ("Not Seen", c4d.Vector(0.5,0,0), True)   
               
            all_objects = get_object_list(doc, layer_not_hit)       
            notseen_obj_list = all_objects['polygon_obj_list']       
                  
            if not notseen_obj_list:   
                c4d.gui.MessageDialog("No Objects on Layer: " + layer_not_hit.GetName())   
            else:   
                unseenfile = c4d.documents.IsolateObjects(doc, notseen_obj_list)   
                print doc.GetDocumentName()   
                  
                orgname = doc.GetDocumentName()   
                orgname = orgname[ :-4 ]   
                print orgname   
                newname = orgname+"_"+layer_not_hit.GetName()   
                print newname   
                if c4d.documents.SaveDocument(unseenfile, newname, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, format=c4d.FORMAT_C4DEXPORT) :   
                    c4d.documents.KillDocument(unseenfile)   
                               
                    for unseenobject in notseen_obj_list:   
                       print "Removing: ", unseenobject.GetName()   
                       unseenobject.Remove()   
          
                c4d.CallCommand(12098) # save cleaned document   
          
        

        kind regards

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

          On 25/06/2015 at 08:33, xxxxxxxx wrote:

          one question remains however:

          How do I prevent the File Save Dialog ß

          kind regards

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

            On 25/06/2015 at 10:34, xxxxxxxx wrote:

            SaveDocument returns false when the file path is not valid, thats why it shows the save as dialog. It returns True when the file path is valid and just saves the file with no dialog:

            c4d.documents.SaveDocument(unseenfile, "/Users/bonsak/Desktop/test.c4d", c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, format=c4d.FORMAT_C4DEXPORT)
            

            -b

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

              On 25/06/2015 at 12:15, xxxxxxxx wrote:

              thanks bonsak.
              this will help me.

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