Save all Objects on a Layer then delete from doc



  • 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/Cinema4DPythonSDK/help/modules/c4d.plugins/BaseData/NodeData/SceneSaverData/index.html#SceneSaverData.Save

    thanks in advance.
    mogh



  • 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



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

    one question remains however:

    How do I prevent the File Save Dialog ß

    kind regards



  • 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



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

    thanks bonsak.
    this will help me.


Log in to reply