5 Replies Latest reply on Jun 23, 2016 8:39 AM by Silly-V

    Looping through all items on a page

    Bob Haslett Level 1

      I am trying to create a script that loops through all the textand path items on a page, sets some text attributes and depending on the name of the item group it with others of the same name. The script I have at the moment sometimes works and sometimes doesn't. It always sets the text attributes, but sometimes will only move say 4 of the seven items with the name xAxisLabel to the group xLabels, other times it will move 3 or 5. Its the same with the path items also, really can't work this out and would appreciate any help



      //Selects the graph before to scale them and turns off the pixel align so that values of 1 decimal place can be applied to strokes


      var sel = doc.selection;




      var item



      var xLabels = layer.groupItems.add();  //create group for xAxis

      var yLabels = layer.groupItems.add();  //create group for xAxis

      var yTicks = layer.groupItems.add();  //create group for xAxis



      //Loops through  ungrouped text items and set horizontal scale, spot black and tabular lining on figures

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


          $.writeln (item)

          item.textRange.characterAttributes.textFont = textFonts.getByName("Metric-Regular");




          //move labels on xAxis into the same group

          if (item.name=="xAxisLabel") {




          //move labels on yAxis into the same group

           if (item.name=="yAxisLabel") {