0 Replies Latest reply on Sep 6, 2016 10:56 AM by wolfeEdition

    Add text frame below results of regexp

    wolfeEdition

      I have a regexp that searches for 3 terms

      (LEFT TRAVEL)

      (RIGHT TRAVEL)

      (BUCKET)

       

      When it finds the terms it adds NOTE A to the textFrame it is found in.

       

      Would it be possible to have NOTE A be Arial Bold without changing the other text in the frame?

       

      And one more addition...would it be possible to create a new textFrame with NOTE A right below the position of the terms found?

       

      Here is the current working code that adds the NOTE A to the text frame.

      #target illustrator
      var doc = app.activeDocument;
      var allText = doc.textFrames;
      
      
      // TEXT TO SEARCH FOR
      var sensorSearch = /\(LEFT TRAVEL\)|\(RIGHT TRAVEL\)|\(BUCKET\)/gi;
      // NOTE TO ADD
      var addNoteA = "NOTE A", result;
      // SEARCH AND CHANGE LOOP
         for (var i = 0; i < allText.length; i++) {
          // SKIP THESE BECAUSE THEY ARE IN THE COLOR TABLE
        if (allText[i].contents == "LEFT TRAVEL CONTROL CIRCUIT" || allText[i].contents == "RIGHT TRAVEL CONTROL CIRCUIT"){
        // SKIP THESE BECAUSE THEY ARE IN THE COLOR TABLE
        }
        else{
                      while (result = sensorSearch.exec(allText[i].contents)) {
                          try {
                              aCon = allText[i].characters[result.index];
        //alert(allText[i].position);
                              aCon.length = result[0].length;
                              aCon.contents = aCon.contents + "\r" + addNoteA;
                          } catch (e) {};
                      }
        }
        }
      

       

       

      Any help would be appreciated!