1 2 Previous Next 55 Replies Latest reply on Aug 17, 2016 10:34 AM by Obi-wan Kenobi

    How to quickly change cell stroke weight

    guillaumeb44426931

      Hi there,

       

      I'm actually working on souscription forms based on tabs. At the moment, the strokes are 1pt weight around each label and content to be added cells. I'm looking for a quick way to set them at 0.5pt.

       

      I've tried the script presented at this address : Script to find/change stroke in tables , but when I launch it returns an error 30614 (incorrect object)

       

      tell application "Adobe InDesign CC 2015"   set currWeight to 1   set newWeight to 0.5   set mytablelist to every cell of every table of every text frame of active document   repeat with x from 1 to (count items of mytablelist)   set myCell to item x of mytablelist   if the bottom edge stroke weight of myCell is currWeight then   set bottom edge stroke weight of myCell to newWeight   end if   if the diagonal line stroke weight of myCell is currWeight then   set diagonal line stroke weight of myCell to newWeight   end if   if the left edge stroke weight of myCell is currWeight then   set left edge stroke weight of myCell to newWeight   end if   if the right edge stroke weight of myCell is currWeight then   set right edge stroke weight of myCell to newWeight   end if   if the top edge stroke weight of myCell is currWeight then   set top edge stroke weight of myCell to newWeight   end if   end repeat end tell

       

      I have the same answer (error 30614).

       

      I don't have any idea of what happened.

       

      Is there someone nice enough to help resolve this problem?

       

      Kind regards,

       

       

      Guillaume

        • 3. Re: How to quickly change cell stroke weight
          Obi-wan Kenobi Adobe Community Professional

          Try this:

           

          s = app.documents.everyItem().stories.everyItem().tables.everyItem().cells.everyItem();  
          s.topEdgeStrokeWeight = s.bottomEdgeStrokeWeight = s.rightEdgeStrokeWeight = s.leftEdgeStrokeWeight = 0.5 ;  
          

           

           

           

          • 4. Re: How to quickly change cell stroke weight
            guillaumeb44426931 Level 1

            Unfortunately, I've already tried this one and I have an issue with it .

             

            The whole document is made with tables . To create some space between the cells, there is a blank cell with 0pt strokes. When I apply this last script, the 0pt strokes become 0,5pt. That's why I'm looking for a way to do a "find & replace" in order to modify only the 1pt strokes, not the others.

             

            Thx anyway

            • 5. Re: How to quickly change cell stroke weight
              karthiks94217840 Level 2

              HI,

               

              Try this

               

              if(app.activeDocument.stories.everyItem().tables.length>0) 

              app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().bottomEdgeStro keWeight = 0;  //Fix your value here

              app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().topEdgeStrokeW eight = 0;  //Fix your value here

              app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().leftEdgeStroke Weight = 0;  //Fix your value here

              app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().rightEdgeStrok eWeight = 0;  //Fix your value here

               

              Best wishes

              KS

              • 6. Re: How to quickly change cell stroke weight
                tpk1982 Level 4

                hope this will give you the solution:

                 

                var myStrokeWeightToFind = 1; 
                
                var myTables = app.documents[0].stories.everyItem().tables.everyItem().getElements(); 
                for(var i = 0; i < myTables.length; i++) { 
                    var myCells = myTables[i].cells; 
                    for (var j = 0; j < myCells.length; j ++) { 
                        if (myCells[j].topEdgeStrokeWeight === myStrokeWeightToFind || 
                        myCells[j].leftEdgeStrokeWeight === myStrokeWeightToFind || 
                        myCells[j].bottomEdgeStrokeWeight === myStrokeWeightToFind || 
                        myCells[j].rightEdgeStrokeWeight === myStrokeWeightToFind) { 
                            myCells[j].topEdgeStrokeWeight=myCells[j].leftEdgeStrokeWeight=myCells[j].bottomEdgeStrokeWeight=myCells[j].rightEdgeStrokeWeight=0.5 
                            } 
                        } 
                    } 
                
                • 7. Re: How to quickly change cell stroke weight
                  guillaumeb44426931 Level 1

                  Hi,
                  Same issue here as the 0pt strokes are turned into 0,5pt strokes.

                   

                  Thx anyway,


                  Kind regards

                  • 8. Re: How to quickly change cell stroke weight
                    guillaumeb44426931 Level 1

                    HI,

                     

                    Thanks for your help.

                     

                    Unfortunately I still have a javascript error (see attached).

                     

                    Kind regards,

                     

                    Guillaume

                     

                     

                    Capture d’écran 2016-08-16 à 15.10.27.jpg

                    • 9. Re: How to quickly change cell stroke weight
                      Obi-wan Kenobi Adobe Community Professional

                      Maybe:

                       

                      var myStrokeWeightToFind = 1;   
                        
                      var myTables = app.documents[0].stories.everyItem().tables.everyItem().getElements();   
                      for(var i = 0; i < myTables.length; i++) {   
                          var myCells = myTables[i].cells;   
                          for (var j = 0; j < myCells.length; j ++) {   
                         
                              if (myCells[j].topEdgeStrokeWeight === myStrokeWeightToFind &&  
                              myCells[j].bottomEdgeStrokeWeight === myStrokeWeightToFind && 
                              myCells[j].rightEdgeStrokeWeight === myStrokeWeightToFind) {   
                                  myCells[j].topEdgeStrokeWeight=myCells[j].leftEdgeStrokeWeight=myCells[j].bottomEdgeStrokeWeight=myCells[j].rightEdgeStrokeWeight=0.5   
                                  }   
                          }   
                      } 
                      

                       

                       

                       

                      • 10. Re: How to quickly change cell stroke weight
                        guillaumeb44426931 Level 1

                        Thx, It partially works.

                        I mean It works until I have a Javascript error (please see attached). Then, It stopped working.

                         

                        Thanks anyway.

                         

                        Kind regards

                         

                        Capture d’écran 2016-08-16 à 15.38.03.jpg

                        • 11. Re: How to quickly change cell stroke weight
                          Obi-wan Kenobi Adobe Community Professional

                          Surely more simple but this works for me:

                           

                          var myStrokeWeightToFind = 1;   
                          var myStrokeWeightToChange = 3;   
                          
                          
                          var myTables = app.documents[0].stories.everyItem().tables.everyItem().getElements();   
                          
                          
                          for(var i = 0; i < myTables.length; i++) {   
                              var myCells = myTables[i].cells;   
                              for (var j = 0; j < myCells.length; j ++) {   
                             
                                  if (myCells[j].topEdgeStrokeWeight === myStrokeWeightToFind &&  
                                      myCells[j].bottomEdgeStrokeWeight === myStrokeWeightToFind && 
                                      myCells[j].rightEdgeStrokeWeight === myStrokeWeightToFind) {   
                                      myCells[j].topEdgeStrokeWeight = myCells[j].leftEdgeStrokeWeight = myCells[j].bottomEdgeStrokeWeight = myCells[j].rightEdgeStrokeWeight = myStrokeWeightToChange   
                                      }   
                                  if (myCells[j].leftEdgeStrokeWeight === myStrokeWeightToFind &&  
                                      myCells[j].bottomEdgeStrokeWeight === myStrokeWeightToFind && 
                                      myCells[j].rightEdgeStrokeWeight === myStrokeWeightToFind) {   
                                      myCells[j].topEdgeStrokeWeight = myCells[j].leftEdgeStrokeWeight = myCells[j].bottomEdgeStrokeWeight = myCells[j].rightEdgeStrokeWeight = myStrokeWeightToChange   
                                      }   
                              }   
                          }
                          
                          
                          for(var i = 0; i < myTables.length; i++) {   
                              var myCells = myTables[i].cells;   
                              for (var j = 0; j < myCells.length; j ++) {   
                             
                                  if (myCells[j].topEdgeStrokeWeight === myStrokeWeightToChange &&  
                                      myCells[j].leftEdgeStrokeWeight === myStrokeWeightToChange && 
                                      myCells[j].rightEdgeStrokeWeight === myStrokeWeightToChange) {   
                                      myCells[j].bottomEdgeStrokeWeight = myStrokeWeightToChange   
                                      }   
                              }   
                          } 
                          

                           

                           

                          … in these cases:

                           

                          Capture d’écran 2016-08-16 à 15.46.35.png

                           

                          Sorry! I'm a [JS] newbie! 

                          • 12. Re: How to quickly change cell stroke weight
                            Obi-wan Kenobi Adobe Community Professional
                            var myStrokeWeightToFind = 3;   
                            var myStrokeWeightToChange = 1;   
                            
                            
                            var myTables = app.documents[0].stories.everyItem().tables.everyItem().getElements();   
                            
                            
                            app.doScript(main, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Change Stroke Weight!");
                            
                            
                            function main() {
                                
                            for (var i = 0; i < myTables.length; i++) {   
                                  var myCells = myTables[i].cells;   
                                  for (var j = 0; j < myCells.length; j ++) {   
                               
                                      if (myCells[j].topEdgeStrokeWeight === myStrokeWeightToFind &&  
                                          myCells[j].bottomEdgeStrokeWeight === myStrokeWeightToFind && 
                                          myCells[j].rightEdgeStrokeWeight === myStrokeWeightToFind) {   
                                          myCells[j].topEdgeStrokeWeight = myCells[j].leftEdgeStrokeWeight = myCells[j].bottomEdgeStrokeWeight = myCells[j].rightEdgeStrokeWeight = myStrokeWeightToChange   
                                         }   
                                      if (myCells[j].leftEdgeStrokeWeight === myStrokeWeightToFind &&  
                                          myCells[j].bottomEdgeStrokeWeight === myStrokeWeightToFind && 
                                          myCells[j].rightEdgeStrokeWeight === myStrokeWeightToFind) {   
                                          myCells[j].topEdgeStrokeWeight = myCells[j].leftEdgeStrokeWeight = myCells[j].bottomEdgeStrokeWeight = myCells[j].rightEdgeStrokeWeight = myStrokeWeightToChange   
                                         }   
                                  }   
                            
                            
                                  for (var j = 0; j < myCells.length; j ++) {   
                               
                                      if (myCells[j].topEdgeStrokeWeight === myStrokeWeightToChange &&  
                                          myCells[j].leftEdgeStrokeWeight === myStrokeWeightToChange && 
                                          myCells[j].rightEdgeStrokeWeight === myStrokeWeightToChange) {   
                                          myCells[j].bottomEdgeStrokeWeight = myStrokeWeightToChange   
                                         }   
                                  }   
                            } 
                            
                            
                            }
                            

                             

                            More readable + Undo! 

                            • 13. Re: How to quickly change cell stroke weight
                              guillaumeb44426931 Level 1

                              Thank you very much but there is still this error 30614 (see attached).

                               

                              Capture d’écran 2016-08-16 à 16.39.06.jpg

                              Really strange, all the previous scripts work until this specific table  :

                              Capture d’écran 2016-08-16 à 16.41.05.jpg

                               

                              The scripts seem to work for some of the horizontal lines and then return the error.

                               

                              Many thanks.

                               

                               

                              Guillaume

                              • 14. Re: How to quickly change cell stroke weight
                                Skemicle Level 3

                                Try this? It may or may not work but it is my attempt =)

                                 

                                 

                                //Scripted by Skemicle

                                if (parseFloat(app.version) < 6)

                                main();

                                else

                                app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Change stroke weight");

                                function main() {

                                    var curweight = 1,

                                    changeweight = .5,

                                    tables = app.documents.everyItem().stories.everyItem().tables.everyItem().cells.everyItem(),

                                    top = tables.topEdgeStrokeWeight,

                                    bottom = tables.bottomEdgeStrokeWeight,

                                    right = tables.rightEdgeStrokeWeight,

                                    left = tables.leftEdgeStrokeWeight;

                                    if(top == curweight){top = changeweight};

                                    if(bottom == curweight){bottom = changeweight};

                                    if(right == curweight){right = changeweight};

                                    if(left == curweight){left = changeweight};

                                }

                                • 15. Re: How to quickly change cell stroke weight
                                  Obi-wan Kenobi Adobe Community Professional

                                  Hi Skemicle,

                                   

                                  I think the way is to apply a label to each cell whose the four strokes are 1 pt!

                                  After that, it could be easy the find each cell with this label and change its strokes!

                                   

                                  … But I'm truly actually unable to write it! 

                                  • 16. Re: How to quickly change cell stroke weight
                                    Obi-wan Kenobi Adobe Community Professional

                                    Always a problem on the left external side! 

                                     

                                    var myStrokeWeightToFind = 1;   
                                    var myStrokeWeightToChange = 0.5;   
                                    
                                    
                                    myCells = app.documents.everyItem().stories.everyItem().tables.everyItem().cells.everyItem().getElements();  
                                    
                                    
                                    app.doScript(main, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Change Stroke Weight!");
                                    
                                    
                                    function main() {
                                        
                                    for (var j = 0; j < myCells.length; j++) {   
                                       
                                              if (myCells[j].topEdgeStrokeWeight === myStrokeWeightToFind){ 
                                                  myCells[j].topEdgeStrokeWeight = myStrokeWeightToChange   
                                                 }   
                                              if (myCells[j].bottomEdgeStrokeWeight === myStrokeWeightToFind){ 
                                                  myCells[j].bottomEdgeStrokeWeight = myStrokeWeightToChange   
                                                 }   
                                              if (myCells[j].rightEdgeStrokeWeight === myStrokeWeightToFind){ 
                                                  myCells[j].rightEdgeStrokeWeight = myStrokeWeightToChange   
                                                 }   
                                    //          if (myCells[j].leftEdgeStrokeWeight === myStrokeWeightToFind){ 
                                    //              myCells[j].letfEdgeStrokeWeight = myStrokeWeightToChange   
                                    //             }   
                                          }   
                                    
                                    
                                    } 
                                    
                                    • 17. Re: How to quickly change cell stroke weight
                                      Laubender Adobe Community Professional & MVP

                                      Hi Guillaume,

                                      here is my take on this.


                                      Since I cannot test with your document, I implemented a little error log.

                                      And I did parted the task into two steps:

                                       

                                      1. First find all the cells with 1 pt strokes on all sides and write their index numbers to an array

                                      2. Then loop that array and do the changes in one go

                                       

                                      The script will run with doScript() so that all actions can be undone in one go.

                                      If something goes wrong in the second part, the script should write an error log to the JavaScript Console of your ESTK App.

                                       

                                      /*
                                          Script by Uwe Laubender
                                         
                                          If all the four stroke weights of a cell are the value of var weight,
                                          write the index of the cell to an array.
                                         
                                          Then loop through that array and apply a new stroke weight to the cell.
                                          For top, bottom, left and right in one go by using the property properties of a cell.
                                      */
                                      
                                      /**
                                      * @@@BUILDINFO@@@ FindAndChangeStrokeWeight-CELLS-of-DOCUMENT.jsx !Version! Tue Aug 16 2016 20:51:12 GMT+0200
                                      */
                                      
                                      // Let's run this in function main and a doScript
                                      // so that you can undo the script's action in one go:
                                      
                                      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
                                      app.doScript
                                          (
                                         
                                          main,
                                          ScriptLanguage.JAVASCRIPT,
                                          [],
                                          UndoModes.ENTIRE_SCRIPT,
                                          "Change Stroke Weight"
                                         
                                          );
                                      
                                      function main()
                                      {
                                      
                                      // Weight to find:
                                      var weight = 1;
                                      // New weight to set:
                                      var newWeight = "0.5 pt";
                                      
                                      // Some checks first:
                                      if(app.documents.length == 0){return};
                                      if(app.documents[0].stories.length == 0){return};
                                      if(app.documents[0].stories.everyItem().tables.length == 0){return};
                                      
                                      // Some variable declarations:
                                      
                                      var doc = app.documents[0];
                                      var allStories = doc.stories.everyItem();
                                      
                                      // IMPORTANT NOTE:
                                      // Variable allCells will NOT CONTAIN cells of
                                      // 1. tables inside cells
                                      // 2. tables inside footnotes
                                      
                                      // To get allCells will take a while, if there are many tables with many cells
                                      // So be patient!
                                      var allCells = allStories.tables.everyItem().cells.everyItem().getElements();
                                      
                                      // resultArray will store the found index numbers of the allCells array:
                                      var resultArray = [];
                                      
                                      // The changeValueObject, that will later be applied as value
                                      // for the properties-property of all found cells:
                                      var changeValueObject =
                                      {
                                          bottomEdgeStrokeWeight : newWeight ,
                                          leftEdgeStrokeWeight : newWeight ,
                                          rightEdgeStrokeWeight : newWeight ,
                                          topEdgeStrokeWeight : newWeight
                                      };
                                      
                                      // Loop through the big allCells array.
                                      // If either of the four conditions is false, loop on to the next cell.
                                      for(var n=0;n<allCells.length;n++)
                                      {
                                          // Four filters:
                                          if(allCells[n].bottomEdgeStrokeWeight != weight){continue};
                                          if(allCells[n].leftEdgeStrokeWeight != weight){continue};
                                          if(allCells[n].rightEdgeStrokeWeight != weight){continue};
                                          if(allCells[n].topEdgeStrokeWeight != weight){continue};
                                         
                                          // Here we gather the filtered out cell's index number only:
                                          resultArray[resultArray.length++] = n;
                                      };
                                      
                                      /*
                                          // At this stage of the script
                                          // we could check the resultArray by e.g. using:
                                         
                                          $.writeln(resultArray.join("\r"));
                                         
                                          // to write a column of index numbers to the JavaScript Console
                                          // of the ESTK (ExtendScript Toolkit App)
                                         
                                      */
                                      
                                      // FINALLY
                                      // Here we do the action
                                      // We loop the resultArray and apply the desired values for IN ONE GO
                                      // by using the properties-property and apply an object as value:
                                      
                                      for(var n=0;n<resultArray.length;n++)
                                      {
                                          // If something goes wrong for whatever reason
                                          // a error log is written to the JavaScript Console of the ESTK:
                                          try{
                                              allCells[resultArray[n]].properties = changeValueObject;
                                          }catch(e)
                                          {
                                              $.writeln(resultArray[n]+"\t"+e.message);
                                          }
                                      }
                                      
                                      };
                                      

                                       

                                      Regards,
                                      Uwe

                                      1 person found this helpful
                                      • 18. Re: How to quickly change cell stroke weight
                                        Obi-wan Kenobi Adobe Community Professional

                                        Cool! Thanks! It works fine! [ of course!  ]

                                         

                                        Uwe, a little question about mine (post#16) [… if time!]:

                                         

                                        Why it doesn't work?    [for my learning!]

                                        • 19. Re: How to quickly change cell stroke weight
                                          Laubender Adobe Community Professional & MVP

                                          Hi Obi-wan,

                                           

                                          I don't know why your script snippet in #16 is not working for you.
                                          With a simple sample table in a document your code is working for me.

                                           

                                          Could you write more about the problems you found with your snippet?

                                          You said: "Always a problem on the left external side!"

                                          What does that exactly mean?

                                           

                                          Can you provide screen shots before/after running your snippet?
                                          Or better: Can you provide a link to a sample document that I can do a test with?

                                           

                                          Regards,
                                          Uwe

                                          • 20. Re: How to quickly change cell stroke weight
                                            Obi-wan Kenobi Adobe Community Professional

                                            The script launched from ESTK failed at line 21:

                                             

                                            Capture d’écran 2016-08-16 à 21.41.55.png

                                             

                                            If I desactive (as comments) the lines 21-22-23, the script works but the left side of the table is not treated!  Weird! 

                                             

                                            Capture d’écran 2016-08-16 à 21.42.34.png

                                            Capture d’écran 2016-08-16 à 21.55.10.png

                                            • 21. Re: How to quickly change cell stroke weight
                                              Skemicle Level 3

                                              I have a script that works. Though i feel like it is basically the same as my previous script plus a for loop

                                               

                                               

                                              /*

                                              Scripted by Skemicle

                                              */

                                              if (parseFloat(app.version) < 6)

                                              main();

                                              else

                                              app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Change Stroke Weight");

                                              function main() {

                                                  var doc = app.documents[0];

                                                  var story = doc.stories.everyItem();

                                                  var cell = story.tables.everyItem().cells.everyItem().getElements();

                                                  var curweight = 1; //enter the stroke weight you want to change from here

                                                  var newweight = .5; // enter the desired stroke weight here

                                                  for(c=0;c<cell.length;c++){

                                                      if(cell[c].topEdgeStrokeWeight == curweight){

                                                          cell[c].topEdgeStrokeWeight = newweight;

                                                      }

                                                      if(cell[c].bottomEdgeStrokeWeight == curweight){

                                                          cell[c].bottomEdgeStrokeWeight = newweight;

                                                      }

                                                      if(cell[c].rightEdgeStrokeWeight == curweight){

                                                          cell[c].rightEdgeStrokeWeight = newweight;

                                                      }

                                                      if(cell[c].leftEdgeStrokeWeight == curweight){

                                                          cell[c].leftEdgeStrokeWeight = newweight;

                                                      }

                                                  }

                                              }

                                              • 22. Re: How to quickly change cell stroke weight
                                                Obi-wan Kenobi Adobe Community Professional

                                                I Have a similar problem with it. The script failed on line 24! 

                                                 

                                                Capture d’écran 2016-08-16 à 21.57.46.png

                                                • 23. Re: How to quickly change cell stroke weight
                                                  Skemicle Level 3

                                                  If you rearranged the script and put the left side change above the right side; would it still error on the left or would it make it to the right before it caused the error?

                                                  • 24. Re: How to quickly change cell stroke weight
                                                    Laubender Adobe Community Professional & MVP

                                                    Hi Obi-wan.

                                                    Ah. Now I see.


                                                    Your script has a problem with the fourth if-condition.

                                                     

                                                    The error message from my German InDesign CS6 v8.1.0 is:

                                                    "Objekt unterstützt Eigenschaft oder Methode letfEdgeStrokeWeight nicht"

                                                     

                                                    Roughly translated to:

                                                    "Object does not support property or method letfEdgeStrokeWeight"

                                                     

                                                    So I think, the big difference between your script and mine here is:

                                                    1. That my script is using a different filter method

                                                    2. That my script will apply all four values of all four properties in one go.

                                                     

                                                    It was a just a gut feeling, an instinct that led me to the conclusion to separate the detection of the cell and the action I want to apply.

                                                    I tried to rewrite your script a bit but I failed. This time on the property bottomEdgeStrokeWeight.

                                                     

                                                    Why the error? Don't know…

                                                     

                                                    Here the not working code where I tried to bind all the four if-conditions together:

                                                     

                                                    var myStrokeWeightToFind = 1;
                                                    var myStrokeWeightToChange = 0.5;
                                                    
                                                    myCells = app.documents.everyItem().stories.everyItem().tables.everyItem().cells.everyItem().getElements();
                                                    
                                                    app.doScript(main, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Change Stroke Weight!");
                                                    
                                                    function main()
                                                    {
                                                        var changeValueObject =
                                                        {
                                                            bottomEdgeStrokeWeight : myStrokeWeightToChange ,
                                                            leftEdgeStrokeWeight : myStrokeWeightToChange ,
                                                            rightEdgeStrokeWeight : myStrokeWeightToChange ,
                                                            topEdgeStrokeWeight : myStrokeWeightToChange
                                                        };
                                                    
                                                        for (var j = 0; j < myCells.length; j++)
                                                        {  
                                                    
                                                            if(
                                                                myCells[j].topEdgeStrokeWeight == myStrokeWeightToFind &&
                                                                myCells[j].bottomEdgeStrokeWeigh == myStrokeWeightToFind &&
                                                                myCells[j].rightEdgeStrokeWeight == myStrokeWeightToFind &&
                                                                myCells[j].leftEdgeStrokeWeight == myStrokeWeightToFind
                                                                )
                                                                {
                                                                    myCells[j].properties = changeValueObject;
                                                                };
                                                    
                                                            };
                                                    };
                                                    

                                                     

                                                    Regards,
                                                    Uwe

                                                    • 25. Re: How to quickly change cell stroke weight
                                                      Skemicle Level 3

                                                      That or the fact that "le'tf'Edge" t and f should be flipped.. that one's hard to see.

                                                      • 26. Re: How to quickly change cell stroke weight
                                                        Skemicle Level 3

                                                        and the ommission of the t of weight in the bottom for Laubender 's rewrite

                                                        • 27. Re: How to quickly change cell stroke weight
                                                          Laubender Adobe Community Professional & MVP

                                                          Hi Skemicle, sorry, I don't get it.

                                                          Where do you see a typo in the last code snippet I posted?
                                                          I cannot detect one.

                                                           

                                                          What do you mean by "that"?

                                                           

                                                          Regards,
                                                          Uwe

                                                          • 28. Re: How to quickly change cell stroke weight
                                                            Laubender Adobe Community Professional & MVP

                                                            Skemicle wrote:

                                                             

                                                            and the ommission of the t of weight in the bottom for Laubender 's rewrite

                                                            That's a typo. Yes. Thank you for posting.

                                                             

                                                            Uwe

                                                            • 29. Re: How to quickly change cell stroke weight
                                                              Laubender Adobe Community Professional & MVP

                                                              After correcting that typo (adding the "t") the script is working!

                                                               

                                                              Thank you,
                                                              Uwe

                                                              • 30. Re: How to quickly change cell stroke weight
                                                                Skemicle Level 3

                                                                "That" was referring to your suggestion about using different filter methods.

                                                                and in your second if statement on line 23 "myCells[j].bottomEdgeStrokeWeigh == myStrokeWeightToFind &&"  it is missing the t for weight myCells[j].letfEdgeStrokeWeight = myStrokeWeightToChange"

                                                                • 31. Re: How to quickly change cell stroke weight
                                                                  Laubender Adobe Community Professional & MVP

                                                                  Here the corrected snippet Obi-wan should test:

                                                                   

                                                                  var myStrokeWeightToFind = 1;
                                                                  var myStrokeWeightToChange = 0.5;
                                                                  
                                                                  myCells = app.documents.everyItem().stories.everyItem().tables.everyItem().cells.everyItem().getElements();
                                                                  
                                                                  app.doScript(main, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Change Stroke Weight!");
                                                                  
                                                                  function main()
                                                                  {
                                                                      var changeValueObject =
                                                                      {
                                                                          bottomEdgeStrokeWeight : myStrokeWeightToChange ,
                                                                          leftEdgeStrokeWeight : myStrokeWeightToChange ,
                                                                          rightEdgeStrokeWeight : myStrokeWeightToChange ,
                                                                          topEdgeStrokeWeight : myStrokeWeightToChange
                                                                      };
                                                                  
                                                                      for (var j = 0; j < myCells.length; j++)
                                                                      { 
                                                                  
                                                                          if(
                                                                              myCells[j].topEdgeStrokeWeight == myStrokeWeightToFind &&
                                                                              myCells[j].bottomEdgeStrokeWeight == myStrokeWeightToFind &&
                                                                              myCells[j].rightEdgeStrokeWeight == myStrokeWeightToFind &&
                                                                              myCells[j].leftEdgeStrokeWeight == myStrokeWeightToFind
                                                                              )
                                                                              {
                                                                                  myCells[j].properties = changeValueObject;
                                                                              };
                                                                  
                                                                          };
                                                                  };
                                                                  

                                                                   

                                                                  Regards,
                                                                  Uwe

                                                                  • 32. Re: How to quickly change cell stroke weight
                                                                    Laubender Adobe Community Professional & MVP

                                                                    Skemicle wrote:

                                                                     

                                                                    "That" was referring to your suggestion about using different filter methods.

                                                                    and in your second if statement on line 23 "myCells[j].bottomEdgeStrokeWeigh == myStrokeWeightToFind &&" it is missing the t for weight myCells[j].letfEdgeStrokeWeight = myStrokeWeightToChange"

                                                                    Now I see.
                                                                    My missing "t" and Obi-wan's typo with "tf" instead of "ft".

                                                                    Thank you very much for your eagle eyes!

                                                                     

                                                                    Uwe

                                                                    • 33. Re: How to quickly change cell stroke weight
                                                                      Obi-wan Kenobi Adobe Community Professional

                                                                      Yes to post#25!  … but the result is the same!

                                                                       

                                                                      Uwe, It's cool you confirm mine can't work! Weird but cool!

                                                                      Yours works nice but only if we have the 4 sides! 

                                                                       

                                                                      Capture d’écran 2016-08-16 à 22.32.41.png

                                                                      • 34. Re: How to quickly change cell stroke weight
                                                                        Laubender Adobe Community Professional & MVP

                                                                        Obi-wan Kenobi wrote:

                                                                        Yours works nice but only if we have the 4 sides!

                                                                        I thought that was the base condition Guillaume was after ?!

                                                                        Am I wrong?

                                                                         

                                                                        Uwe

                                                                        • 35. Re: How to quickly change cell stroke weight
                                                                          Obi-wan Kenobi Adobe Community Professional

                                                                          … And the result (at post#32):

                                                                           

                                                                          Capture d’écran 2016-08-16 à 22.39.09.png

                                                                          • 36. Re: How to quickly change cell stroke weight
                                                                            Obi-wan Kenobi Adobe Community Professional

                                                                            Yes!  Right! 

                                                                             

                                                                            If time, I would try to include an UI allowing the op to choose what beginning and final weight, including color and aspect (line, dots …), and what side (top, left, bottom and right).

                                                                             

                                                                             

                                                                            • 37. Re: How to quickly change cell stroke weight
                                                                              Laubender Adobe Community Professional & MVP

                                                                              Obi-wan Kenobi wrote:

                                                                               

                                                                              … And the result (at post#32):

                                                                              Urgs…

                                                                              I have to see that document to download and for testing.
                                                                              But not now. I'm half asleep before my screen.

                                                                               

                                                                              Uwe

                                                                              • 38. Re: How to quickly change cell stroke weight
                                                                                Obi-wan Kenobi Adobe Community Professional

                                                                                Skemicle [at post#23]: I've tried and same bad result!

                                                                                • 39. Re: How to quickly change cell stroke weight
                                                                                  Skemicle Level 3

                                                                                  Here you go Obi-wan

                                                                                   

                                                                                   

                                                                                  var myStrokeWeightToFind = Number(prompt("What is your starting weight?", 1,"Current Stroke Weight"));
                                                                                  var myStrokeWeightToChange = Number(prompt("desired result?", 0.5,  "End Stroke Weight"));

                                                                                   

                                                                                   

                                                                                  myCells = app.documents.everyItem().stories.everyItem().tables.everyItem().cells.everyItem().getEle ments();   

                                                                                   

                                                                                   

                                                                                  app.doScript(main, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Change Stroke Weight!"); 

                                                                                   

                                                                                   

                                                                                  function main() { 

                                                                                  for (var j = 0; j < myCells.length; j++) {
                                                                                        if (myCells[j].topEdgeStrokeWeight === myStrokeWeightToFind){  
                                                                                            myCells[j].topEdgeStrokeWeight = myStrokeWeightToChange
                                                                                           }
                                                                                        if (myCells[j].bottomEdgeStrokeWeight === myStrokeWeightToFind){  
                                                                                            myCells[j].bottomEdgeStrokeWeight = myStrokeWeightToChange
                                                                                           }
                                                                                        if (myCells[j].rightEdgeStrokeWeight === myStrokeWeightToFind){  
                                                                                            myCells[j].rightEdgeStrokeWeight = myStrokeWeightToChange
                                                                                           }
                                                                                        if (myCells[j].leftEdgeStrokeWeight === myStrokeWeightToFind){  
                                                                                            myCells[j].leftEdgeStrokeWeight = myStrokeWeightToChange
                                                                                           }
                                                                                    }

                                                                                   

                                                                                   

                                                                                  1 2 Previous Next