8 Replies Latest reply on Jul 16, 2013 1:19 PM by S Hopkins

    find rectangle fillcolor below 100

    indegn5

      Hi Forum,

       

      I would like to find rectangle, which has fill color below 100 and moved to a layer.

       

      Also, would like to move the rectangle with transparency applied to it  to be moved to a next layer.

       

      I have to bit, but it find only one rectangle and move to layer and all other are left as it is.

       

       

        app.findObjectPreferences.fillTint =60;
        var myfound = app.findObject();
        for (i=0; i>myfound.length; i++) {
            app.select(myfound[i]);
            app.selection[0].move(app.activeDocument.layers.item("transparency"))
            }

       

      myDoc = app.activeDocument;

      var myFrame = myDoc.rectangles;

      if (myFrame.fillTransparencySettings.blendingSettings.opacity != 100) {

      app.select(myFrame);

      app.selection[0].move(app.activeDocument.layers.item("transparency")

      }

       

      thanks for your help in advance.

      Bob

        • 1. Re: find rectangle fillcolor below 100
          S Hopkins Adobe Community Professional

          I am a little confused. Will your rectangles have both fill tint and transparency?

          If you use app.findObject() to get an array of page items, make sure you set findChangeObjectOptions:

          findChageOptions();

          function findChangeOptions() {

          var optionPref = app.findChangeObjectOptions;

          optionPref.includeHiddenLayers = true;

          //can be TEXT_FRAMES_TYPE, ALL_FRAMES_TYPE, UNASSIGNED_FRAMES_TYPE;

          optionPref.objectType=ObjectTypes.GRAPHIC_FRAMES_TYPE;

          optionPref.includeLockedLayersForFind=true;

          optionPref.includeMasterPages=true;

          }

          Also, don't use select for moving items to layers. Parse through the array of found items (frameArr) and set the itemLayer property to a reference to the layer (layerRef):

          var myDoc = app.activeDocument;

          var frameArr = myDoc.rectangles;

          var layerRef = myDoc.layers.itemByName("Transparency");

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

              if (frameArr[i].fillTransparencySettings.blendingSettings.opacity < 100) {

                  frameArr[i].itemLayer=layerRef;

              }

          }

          Hope this helps.

          • 2. Re: find rectangle fillcolor below 100
            indegn5 Level 1

            Hi Hopkins,

             

            Thanks for your answer and solutions.

             

            I have got result for transparency, but when i tried to moved all the rectangles below 100% tint, it moves all the rectangles including 100% tint to the layers.

             

            var myDoc = app.activeDocument;

             

            var frameArr = myDoc.rectangles;

             

            var layerRef = myDoc.layers.itemByName("Miki");

             

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

             

              if (frameArr[i].fillTint < 100) {

             

                    frameArr[i].itemLayer=layerRef;

             

                }

             

            }

             

            and about transparency;

            without mentioning object "rectangle", how can i move any object which has transparency options applied on it to a particular layers...

             

            thanks so much for your solution.....

            • 3. Re: find rectangle fillcolor below 100
              [Jongware] Most Valuable Participant

              Draw a rectangle. Fill it with 100% black. Select it. Run this script

               

              alert (app.selection[0].fillTint);
              

               

              and see what value it shows. Change the tint to 99% and run the script. Then change it back to 100% and run the script again.

              • 4. Re: find rectangle fillcolor below 100
                indegn5 Level 1

                Hi [Jongware],

                 

                After following your instruction, while checking 100% black, alert value is;  -1 for 100 and 99 for  99%.

                 

                It means that it is not possible to select rectangle without defining the specific value.

                 

                However, please advice me, if there any solution to select and move the rectangle which has fill color below 100% value.

                 

                Many thanks [Jongware]. J.

                • 5. Re: find rectangle fillcolor below 100
                  indegn5 Level 1

                  Hi,

                   

                  I'm trying to move different percentage fillTints to different Layers. As Mr. [Jongware] said, I can't able to move 100% fillTint to move to 100% Layer.

                   

                   

                  var myDoc = app.activeDocument;

                   

                  var frameArr = myDoc.rectangles;

                   

                  var layerRef = myDoc.layers.itemByName("80% Tints");

                   

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

                    if (frameArr[i].fillTint ==80) {                // if I use value 100 it is not considered as value 100 (as -1 infact). And it is not moved or it moves to the layers alongwith the other % tints, where commanded to move.

                  app.select(frameArr[i]);

                          frameArr[i].itemLayer="80% Tints";

                  }

                   

                  else {

                      

                  frameArr[i].itemLayer="Mixed% Tints";

                  }

                  }

                  • 6. Re: find rectangle fillcolor below 100
                    indegn5 Level 1

                    Well!

                    I found the way to move 100% fillTints.

                     

                    app.findObjectPreferences.fillTint = -1;

                          var myfound = app.findObject();

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

                              app.select(myfound[i]);

                              myfound[i].itemLayer = "100% fillTints";

                              }

                     

                    Can i get help from forum to do as per below request,

                     

                    100% tints should not be moved alongwith the "tints less than 100% value".

                     

                    Because again i have to move the 100% tints to the original location using above script.

                    • 7. Re: find rectangle fillcolor below 100
                      indegn5 Level 1

                      HI Forum,

                       

                      This is what i'm lookig for.

                       

                      To move different fillTints of the rectangle to different Layer.

                      i.e. 20% of fillTint to be moved to itemLayer = "20% fillTints".

                      30% to itemLayer = "30% fillTints"

                       

                      the above 2 script moved the 100% fillTints to separate Layers and moves rest all the fillTints to one Layer.

                       

                      HOw can I find different fillTints to move on its Own Layers.

                      • 8. Re: find rectangle fillcolor below 100
                        S Hopkins Adobe Community Professional

                        I have been playing with your script problem while testing InDesign CC. I have found a small problem with this version; haven't tested in other versions yet. Anyway, notice in the code below that I am getting the ID for all rectangles and then resolving the reference to the rectangles using the ID. If I use

                        rectArr = docRef.rectangles; the loop that processes the rectangles does not produce consistent results.

                        Just thought I should mention why I am using the rectangle id's. It just works consistently.

                         

                        /*Moves rectangles with 100% fill tint to specified layer;

                        rectangles with other tint values are moved to layers named using tint value

                        tested in Adobe InDesign CC*/

                        var docRef = app.documents.item(0);

                        //identify layer for items having 100% fill tint

                        var testLayer = docRef.layers.itemByName("Test");

                        var rectArr = docRef.rectangles.everyItem().id;

                        var tintVal, layerRef, rectRef, itemId;

                        //parse through list of rectangle ids and move to layers depending on tint value

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

                            itemId = rectArr[i];

                            rectRef = docRef.rectangles.itemByID(itemId);

                            tintVal = rectRef.fillTint;

                            if (tintVal == -1) {

                                rectRef.itemLayer = testLayer;

                            } else {

                                layerRef = checkLayer (docRef, tintVal);

                                rectRef.itemLayer = layerRef;

                            }

                        }

                         

                        //checks to see if layer exists; if not, layer is created;

                        //note isValid only works with later versions of InDesign; otherwise check for null value

                        function checkLayer (docRef, tintVal) {

                            var testLayer;

                            var layerName = ("" + tintVal + "% fillTints");

                            if (!docRef.layers.itemByName(layerName) .isValid){

                            testLayer = docRef.layers.add({name:layerName});

                            } else {

                             testLayer = docRef.layers.itemByName(layerName);

                            }

                             return testLayer;

                        }