3 Replies Latest reply on Feb 17, 2015 4:30 PM by julioc4816867

    Export 2 Layers to a new document

    julioc4816867 Level 1

      Hello, I need your help, I need export 2 layer to a new document, It's possible? sorry my bad english, thanks

       

      example:

      ejemplo.jpg

      01111.jpg

      similar script to export 1 layer to .Ai

      
      
      var doc = app.activeDocument;
      var start = true;
      var ver = 12;
      var saveOptions = new IllustratorSaveOptions();
      switch (ver){
        case 3: saveOptions.compatibility = Compatibility.ILLUSTRATOR3;
        break;
        case 8: saveOptions.compatibility = Compatibility.ILLUSTRATOR8;
        break;
        case 9: saveOptions.compatibility = Compatibility.ILLUSTRATOR9;
        break;
        case 10: saveOptions.compatibility = Compatibility.ILLUSTRATOR10;
        break;
        case 11: saveOptions.compatibility = Compatibility.ILLUSTRATOR11;
        break;
        case 12: saveOptions.compatibility = Compatibility.ILLUSTRATOR12;
        break;
      }
      saveOptions.overprint = PDFOverprint.PRESERVEPDFOVERPRINT;
      if (ver <= 9) {
        saveOptions.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;
      }
      if (ver >= 7) {
        saveOptions.embedLinkedFiles = false;
      }
      if (ver >= 9) {
        saveOptions.fontSubsetThreshold = 100;
        saveOptions.embedICCProfile = false;
      }
      if (ver >= 10) {
        saveOptions.compressed = true;
        saveOptions.pdfCompatible = false;
      }
      var preffix = "_sb_";
      var suffix = "";
      var noname = "0";
      
      
      if (documents.length > 0){
        if (doc.saved==false) {
        alert('File must be saved before execute script!!!','saveLayersToAI',true);
        start = false;
        }
        if (start){
        fullDocName = doc.fullName;
        for (j=0; j<doc.layers.length; j++){
        if ((doc.layers[j].printable == true)&&(doc.layers[j].locked == false)) {
        doc.layers[j].locked = true;
        nameLayer = doc.layers[j].name;
        for (i=0; i<doc.layers.length; i++){
        if (doc.layers[i].locked == false){
        doc.layers[i].visible = true;
        doc.layers[i].remove();
        i = i-1;
        }
        }
        for (i=0; i<doc.layers.length; i++){
        doc.layers[i].locked = false;
        doc.layers[i].visible = true;
        }
        var param = doc.name.split('.');
        realDocName = param[0];
        if (nameLayer == noname) docName = preffix+realDocName+suffix;
        else docName = preffix+realDocName+'_'+nameLayer+suffix;
        var saveName = new File ( doc.path + "/" + docName );
        doc.saveAs( saveName, saveOptions );
        doc.close(SaveOptions.DONOTSAVECHANGES);
        doc = null;
        app.open (fullDocName);
        doc = app.activeDocument;
        }
        }
        }
      }