5 Replies Latest reply on Mar 26, 2018 6:16 AM by andrewb66529688

    Script to find/change stroke in tables

    gwhPoster Level 1

      Hi everyone,

      I posted this very same question about a month ago but I got no reply so I thought I'd try again. Even if I can't obtain a free script that will do what I need, I'm happy to look at paying for one if someone can point me in the right direction.

      I'm looking for a script that will target the stroke weight in tables and change them to a lighter weight, eg. from 0.5pt to 0.3pt.

       

      I have a script that targets the fill at the following url:

       

      http://forums.adobe.com/thread/681944

       

      ...but I'm looking for one that targets the stroke.

       

      Just wondering if anyone might know where I can find one?

       

      Thanks

        • 1. Re: Script to find/change stroke in tables
          csm_phil Level 4

          Hi Poster,

           

          I have modifed the the Jongware JS code, I have inlcuded the Stroke weight options onto the dialog box.

           

          Please check the below JS code.

           

           

          myDialog = app.dialogs.add ({name:"Recolor Tables",canCancel:true});
          swatchlist = app.activeDocument.swatches.everyItem().name;
          with (myDialog)
          {
           with (dialogColumns.add())
           {
            with (borderPanels.add())
            {
             staticTexts.add ({staticLabel:"Find"});
             swf = dropdowns.add ({stringList:swatchlist, selectedIndex:0});
             tbf = percentComboboxes.add({editValue:100, largeNudge:10, stringList:["25", "50", "75", "100"] });
             tbfStrk = measurementEditboxes.add({editValue:0.5});
            }
            with (borderPanels.add())
            {
             staticTexts.add ({staticLabel:"Replace"});
             swr = dropdowns.add ({stringList:swatchlist, selectedIndex:0});
             tbr = percentComboboxes.add({editValue:100, largeNudge:10, stringList:["25", "50", "75", "100"] });
             tbrStrk = measurementEditboxes.add({editValue:0.33});
            }
            with (borderPanels.add())
            {
             dostrokes = checkboxControls.add({staticLabel:"Change strokes", checkedState:true});
             dofills = checkboxControls.add({staticLabel:"Change fills", checkedState:true});
            }
           }
          }
          if (!myDialog.show() || !(dostrokes.checkedState || dofills.checkedState))
          {
           myDialog.destroy();
           exit(0);
          }
          findtint = tbf.editValue;
          findStrk = tbfStrk.editValue;
          findswatch = app.activeDocument.swatches.item(swf.selectedIndex);
          changetint = tbr.editValue;
          changeStrk = tbrStrk.editValue;
          changeswatch = app.activeDocument.swatches.item(swr.selectedIndex);
          strokes = dostrokes.checkedState;
          fills = dofills.checkedState;
          fillchanges = 0;
          strokechanges = 0;
          st = app.activeDocument.stories;
          for (s=0; s<st.length; s++)
          {
           tb = st[s].tables;
           for (t=0; t<tb.length; t++)
           {
            tab = tb[t];
            for (c=0; c<tab.cells.length; c++)
            {
             if (fills && tab.cells[c].fillColor == findswatch && tab.cells[c].fillTint == findtint)
             {
              fillchanges++;
              tab.cells[c].properties = {fillColor:changeswatch, fillTint:changetint};
             }
             if (strokes)
             {
              s = false;
              if (tab.cells[c].topEdgeStrokeColor == findswatch && tab.cells[c].topEdgeStrokeTint == findtint && tab.cells[c].topEdgeStrokeWeight == findStrk)
              {
               s = true;
               tab.cells[c].properties = {topEdgeStrokeColor:changeswatch, topEdgeStrokeTint:changetint, topEdgeStrokeWeight:changeStrk};
              }
              if (tab.cells[c].bottomEdgeStrokeColor == findswatch && tab.cells[c].bottomEdgeStrokeTint == findtint && tab.cells[c].bottomEdgeStrokeWeight == findStrk)
              {
               s = true;
               tab.cells[c].properties = {bottomEdgeStrokeColor:changeswatch, bottomEdgeStrokeTint:changetint, bottomEdgeStrokeWeight:changeStrk};
              }
              if (tab.cells[c].leftEdgeStrokeColor == findswatch && tab.cells[c].leftEdgeStrokeTint == findtint && tab.cells[c].leftEdgeStrokeWeight == findStrk)
              {
               s = true;
               tab.cells[c].properties = {leftEdgeStrokeColor:changeswatch, leftEdgeStrokeTint:changetint, leftEdgeStrokeWeight:changeStrk};
              }
              if (tab.cells[c].rightEdgeStrokeColor == findswatch && tab.cells[c].rightEdgeStrokeTint == findtint && tab.cells[c].rightEdgeStrokeWeight == findStrk)
              {
               s = true;
               tab.cells[c].properties = {rightEdgeStrokeColor:changeswatch, rightEdgeStrokeTint:changetint, rightEdgeStrokeWeight:changeStrk};
              }
              if (s)
               strokechanges++;
             }
            }
           }
          }
          ch = "No changes made";
          if (fillchanges)
          {
           ch = fillchanges+" fills changed";
           if (strokechanges)
            ch += "\n"+strokechanges+" strokes changed";
          } else if (strokechanges)
            ch = strokechanges+" strokes changed";
          alert (ch);
          

           

           

          thx

          csm_phil

          • 2. Re: Script to find/change stroke in tables
            livingmedia

            Hello.

             

            I am having a little trouble with this script. I have Indesign cs 5.5 and the script work for the first 3 table then the mouse just spins for hours and never does more then 3 tables on a page no matter how long i wait. The sequence seems to be that it does the first table, skips the second then does the third then goes back and does the second then stops. Can you please tell me how to fix this or post the modified code. Thank you in advance. I really appreciate it.

            • 3. Re: Re: Script to find/change stroke in tables
              csm_phil Level 4

              Hi Livingmedia,

               

              I have modified the above js code, Please check.

               

              myDialog = app.dialogs.add ({name:"Recolor Tables",canCancel:true});  
              swatchlist = app.activeDocument.swatches.everyItem().name;  
              with (myDialog)  
              {  
               with (dialogColumns.add())  
               {  
                with (borderPanels.add())  
                {  
                 staticTexts.add ({staticLabel:"Find"});  
                 swf = dropdowns.add ({stringList:swatchlist, selectedIndex:0});  
                 tbf = percentComboboxes.add({editValue:100, largeNudge:10, stringList:["25", "50", "75", "100"] });  
                 tbfStrk = measurementEditboxes.add({editValue:0.5});  
                }  
                with (borderPanels.add())  
                {  
                 staticTexts.add ({staticLabel:"Replace"});  
                 swr = dropdowns.add ({stringList:swatchlist, selectedIndex:0});  
                 tbr = percentComboboxes.add({editValue:100, largeNudge:10, stringList:["25", "50", "75", "100"] });  
                 tbrStrk = measurementEditboxes.add({editValue:0.33});  
                }  
                with (borderPanels.add())  
                {  
                 dostrokes = checkboxControls.add({staticLabel:"Change strokes", checkedState:true});  
                 dofills = checkboxControls.add({staticLabel:"Change fills", checkedState:true});  
                }  
               }  
              }  
              if (!myDialog.show() || !(dostrokes.checkedState || dofills.checkedState))  
              {  
               myDialog.destroy();  
               exit(0);  
              }  
              findtint = tbf.editValue;  
              findStrk = tbfStrk.editValue;  
              findswatch = app.activeDocument.swatches.item(swf.selectedIndex);  
              changetint = tbr.editValue;  
              changeStrk = tbrStrk.editValue;  
              changeswatch = app.activeDocument.swatches.item(swr.selectedIndex);  
              strokes = dostrokes.checkedState;  
              fills = dofills.checkedState;  
              fillchanges = 0;  
              strokechanges = 0;  
              tb = app.activeDocument.stories.everyItem().tables.everyItem().getElements();  
               for (t=tb.length-1; t>=0; t--)  
               {  
                tab = tb[t];  
                for (c=0; c<tab.cells.length; c++)  
                {  
                 if (fills && tab.cells[c].fillColor == findswatch && tab.cells[c].fillTint == findtint)  
                 {  
                  fillchanges++;  
                  tab.cells[c].properties = {fillColor:changeswatch, fillTint:changetint};  
                 }  
                 if (strokes)  
                 {  
                  s = false;  
                  if (tab.cells[c].topEdgeStrokeColor == findswatch && tab.cells[c].topEdgeStrokeTint == findtint && tab.cells[c].topEdgeStrokeWeight == findStrk)  
                  {  
                   s = true;  
                   tab.cells[c].properties = {topEdgeStrokeColor:changeswatch, topEdgeStrokeTint:changetint, topEdgeStrokeWeight:changeStrk};  
                  }  
                  if (tab.cells[c].bottomEdgeStrokeColor == findswatch && tab.cells[c].bottomEdgeStrokeTint == findtint && tab.cells[c].bottomEdgeStrokeWeight == findStrk)  
                  {  
                   s = true;  
                   tab.cells[c].properties = {bottomEdgeStrokeColor:changeswatch, bottomEdgeStrokeTint:changetint, bottomEdgeStrokeWeight:changeStrk};  
                  }  
                  if (tab.cells[c].leftEdgeStrokeColor == findswatch && tab.cells[c].leftEdgeStrokeTint == findtint && tab.cells[c].leftEdgeStrokeWeight == findStrk)  
                  {  
                   s = true;  
                   tab.cells[c].properties = {leftEdgeStrokeColor:changeswatch, leftEdgeStrokeTint:changetint, leftEdgeStrokeWeight:changeStrk};  
                  }  
                  if (tab.cells[c].rightEdgeStrokeColor == findswatch && tab.cells[c].rightEdgeStrokeTint == findtint && tab.cells[c].rightEdgeStrokeWeight == findStrk)  
                  {  
                   s = true;  
                   tab.cells[c].properties = {rightEdgeStrokeColor:changeswatch, rightEdgeStrokeTint:changetint, rightEdgeStrokeWeight:changeStrk};  
                  }  
                  if (s)  
                   strokechanges++;  
                 }  
                }  
              }
              ch = "No changes made";  
              if (fillchanges)  
              {  
               ch = fillchanges+" fills changed";  
               if (strokechanges)  
                ch += "\n"+strokechanges+" strokes changed";  
              } else if (strokechanges)  
                ch = strokechanges+" strokes changed";  
              alert (ch); 
              

               

               

              thx,

              csm_phil

              1 person found this helpful
              • 4. Re: Script to find/change stroke in tables
                BasDerks54

                This made my day!! You rock mister!

                • 5. Re: Re: Script to find/change stroke in tables
                  andrewb66529688

                  This is a great script, and have used it often, is it possible to select on stroke colour/weight
                  And change another parameter such as cell width or even the first cell width