10 Replies Latest reply on Jul 23, 2013 5:30 AM by Laubender

    New help! from forum

    artCraft2

      Hi Everybody inside forum..

       

      I really need a great help from you forum...

       

      I want to cut a box which has "effects: transparency settings: gradient Feather settings: applied" and paste it on layer called "gradient".

       

      i tried like this;

      doc = app.activeDocument.rectangles.everyItem();

      for (i=0; i>doc.length; i++) {

      if(doc.transparencySettings.gradientFeatherSettings == true) {

      doc[i].itemLayer = "Gradient"

      }}

       

      but, i can't able to move the rectangle which has Gradient applied.

       

      Help please forum...

       

      Androse!!.

        • 1. Re: New help! from forum
          Jump_Over Level 5

          Hi,

           

          rec = app.activeDocument.rectangles.everyItem().getElements();
          for (i = 0; i < rec.length; i++) {
               if(rec.transparencySettings.gradientFeatherSettings.applied == true) {
                    doc[i].itemLayer = app.activeDocument.layers.item("Gradient");
               } }
          

           

          Jarek

          • 2. Re: New help! from forum
            artCraft2 Level 1

            Hi Jump_Over!

             

            Thanks for your help!

             

            When i tried this in CS3, it is saying "undefined is not an object" highlighting on if statement.

             

            and when i tried this in CS5.. the default gradient is applied newly to all the images. I'm just tring to move the rectangles which has the gradient applied already.

             

            Please help on this...

            • 3. Re: New help! from forum
              Laubender Adobe Community Professional & MVP

              @Jarek – it seems that your code is a bit "garbled"…

               

              @artCraft2 – Jarek's code should have thrown an error both in CS3 and CS5.

               

              Try the following based on Jarek's lines:

               

              //Define the name of the layer here:
              var layerName = "Gradient";
              
              var doc = app.documents[0];
              rec = doc.rectangles.everyItem().getElements();
              
              for (i = 0; i < rec.length; i++){
                  if(rec[i].transparencySettings.gradientFeatherSettings.applied === true) {
                      rec[i].itemLayer = doc.layers.itemByName(layerName);
                      }; 
                  };
              

               

              Annotations:
              The script assumes that the layer named "Gradient" is not locked.

              The script assumes that the rectangles that will be moved to layer "Gradient" are not locked.
              The scope of the script are all rectangle objects on the first level (not nested or anchored ones)

               

              Uwe

              • 4. Re: New help! from forum
                Jump_Over Level 5

                Hi,

                 

                Is garbled a lot indeed . It was "A Beer Too Far", I am afraid.

                 

                Jarek

                • 5. Re: New help! from forum
                  artCraft2 Level 1

                  Hi Jarek!

                   

                  I'm sorry for the previous reply, it works indeed. the error is ..

                   

                  rec = app.activeDocument.rectangles.everyItem().getElements();

                  for (i = 0; i < rec.length; i++) {

                       if(rec[i].transparencySettings.gradientFeatherSettings.applied == true) {

                            rec[i].itemLayer = app.activeDocument.layers.item("Gradient");  //where bold is applied is the typo error.

                       } }

                  Many thanks for the support.

                   

                  Any now, i can able to move only the transparency gradient, How do i move the rectangles if has gradient Swatch.

                   

                  WOuld be a great help....

                  • 6. Re: New help! from forum
                    artCraft2 Level 1

                    Hi Jarek!,

                     

                    for clearance..

                     

                     

                    var layerName = "Gradient";

                     

                    var doc = app.documents[0];

                    rec = doc.rectangles.everyItem().getElements();

                     

                    for (i = 0; i < rec.length; i++){

                        if(rec[i].hasOwnProperty("gradientStops")) {  // to move the rectangle which has gradient swatches...

                            rec[i].itemLayer = doc.layers.itemByName(layerName);

                            };

                        };

                    • 7. Re: New help! from forum
                      Jump_Over Level 5

                      Hi,

                       

                      I think that "if" statement should look like:

                       

                      if( rec[i].fillColor.getElements()[0].constructor.name == "Gradient")
                      

                       

                      Jarek

                      • 8. Re: New help! from forum
                        artCraft2 Level 1

                        Thanks Jarek!,,

                         

                        what is difference between

                         

                        if( rec[i].fillColor.constructor.name == "Gradient") & \\ it is also working

                        if( rec[i].fillColor.getElements()[0].constructor.name == "Gradient")\\ it is also working

                        • 9. Re: New help! from forum
                          artCraft2 Level 1

                          Very very thanks to you Jarek!!!!!

                           

                          A great help on time indeed...

                           

                          Much appreciate to you....

                           

                          Androse

                          • 10. Re: New help! from forum
                            Laubender Adobe Community Professional & MVP

                            @Androse – the getElements()[0] will resolve the specifier of the object in all (most?) cases.

                             

                            Here an example:

                             

                            If you take a Class of objects like "PageItems" you always get back a "PageItem", if you ask for the costructor name.

                            Never the Sub-Class.

                            PageItems may consist of "Rectangles", "Ovals", "Polygons", "TextFrames" etc.pp.

                             

                            If you resolve a specific PageItem out of the pageItems class with "myPageItem.getElements()[0].constructor.name" you get the specific type, "Rectangle", "Oval", "Polygon", "TextFrame" etc.

                             

                            app.documents[0].pageItems[0].getElements()[0].constructor.name;
                            

                             

                            opposed to:

                             

                            app.documents[0].pageItems[0].constructor.name;
                            

                             

                            Uwe