5 Replies Latest reply on Aug 3, 2017 10:27 AM by pixxxel schubser

    How to create the group in the script

    saranr37921948 Level 1

      How to create the group in the script

       

      is taken naming is Garments folder layers

       

      example 3 layers

      • Red
      • Blue
      • Green

       

      Screen Shot 2017-08-03 at 3.45.42 PM.png

       

       

      I needed Art group inside

      3 group folders

      • Red
      • Blue
      • Green

      Screen Shot 2017-08-03 at 3.48.49 PM.png

        • 1. Re: How to create the group in the script
          natrev Level 3

          Hi Saranraj,

           

          Try this..

           

          var docRef=app.activeDocument;
          var LsetGarmants=docRef.layerSets.getByName("Garments");
          var LsetART=docRef.layerSets.getByName("ART");
          var len=LsetGarmants.layers.length;
          if(len>0){
              for(var i=0; i<len;i++){
                  if(LsetGarmants.layers[i].typename=="LayerSet") continue;
                  flg=LsetART.layerSets.add();
                  flg.name=LsetGarmants.layers[i].name;
              }
          }
          

           

           

           

          -yajiv

          1 person found this helpful
          • 2. Re: How to create the group in the script
            saranr37921948 Level 1

            thank you very much it's working

             

            layers

            • Red
            • Blue
            • Green

             

            Group

            • Green
            • Blue
            • Red

             

            the group folder align change

             

            it's possible the same align layer

             

             

            Screen Shot 2017-08-03 at 6.10.49 PM 1.png

            • 3. Re: How to create the group in the script
              natrev Level 3

              Hi Saranraj,

               

              Try this one. If its working please mark as correct answer.

               

              var docRef=app.activeDocument;
              var LsetGarmants=docRef.layerSets.getByName("Garments");
              var LsetART=docRef.layerSets.getByName("ART");
              var len=LsetGarmants.layers.length;
              if(len>0){
                  for(var i=len-1; i>0;i--){
                      if(LsetGarmants.layers[i].typename=="LayerSet") continue;
                      flg=LsetART.layerSets.add();
                      flg.name=LsetGarmants.layers[i].name;
                  }
              }
              

               

               

              - yajiv

              • 4. Re: How to create the group in the script
                saranr37921948 Level 1

                this coding Run one folder is missing

                • 5. Re: How to create the group in the script
                  pixxxel schubser MVP & Adobe Community Professional

                  natrevs code is close

                   

                   

                  With a few changes

                  var docRef=app.activeDocument;
                  var LsetGarmants=docRef.layerSets.getByName("Garments");
                  var len=LsetGarmants.layers.length;
                  var LsetART=docRef.layerSets.getByName("Art");
                  if (len>0 && LsetART.layers.length == 0) {
                      for (var i=len-1; i>=0; i--) {
                          if (LsetGarmants.layers[i].kind != LayerKind.NORMAL) {continue};
                          flg=LsetART.layerSets.add();
                          flg.name=LsetGarmants.layers[i].name;
                      }
                  } else { alert ("wrong structure"); }
                  

                   

                  Have fun

                   

                  1 person found this helpful