3 Replies Latest reply on Jun 9, 2016 1:34 PM by openbracket

    Retain layer names when outlining text

    openbracket

      I would like to know if there is a way to retain the names of text objects/layers when the text is converted to outlines, using scripting.

       

      I create files with dozens of text layers (player names on the back of sports jerseys) and have to send the .ai file to the manufacturers. This means that I have to outline the text, but when I do so, the layers all lose their names and all become "<Group>".

       

      Can anyone think of a way to name these layers with the text they contain?

        • 1. Re: Retain layer names when outlining text
          pixxxel schubser MVP & Adobe Community Professional

          Hi openbracket,

          it's impossible, if the text is outlined.

           

          But it is possible for text and outline the text through script (be sure that the selected text is only filled and without stroke and/or effects)

          You can try something like this:

          // required: an opened document with one selected text frame
          var aDoc = app.activeDocument;
          var aSel = aDoc.selection;
          if (aSel[0].typename =="TextFrame") {
              if (aSel[0].characters.length < 40) {
              var newName = aSel[0].contents;
              } else {
              newName = aSel[0].contents.substr(0, 39);
              }
          aSel[0].createOutline();
          aSel = aDoc.selection;
          // name of the new Group = contents or part of contents of selected text frame
          aSel[0].name = newName;
          }
          

           

           

          Have fun

           

          1 person found this helpful
          • 2. Re: Retain layer names when outlining text
            openbracket Level 1

            Wow, thanks for that pixxxel schubser. I think I can tell what's going on in there. I'll give it a go!

            • 3. Re: Retain layer names when outlining text
              openbracket Level 1

              Thank you so much for your code! It got me started on the route to a solution:

               

              var doc = app.activeDocument;  // the document with only the items you want to outline
              doc.selectObjectsOnActiveArtboard( ); // select all items on the artboard
              
              
              for (var i = 0; i < app.selection.length; i++) { // loop through all selected items
                  if (app.selection[i].characters.length < 40) { // if the name is less than 40 char
                      var newName = app.selection[i].contents; // name it with the contents
                  } else {  
                      newName = app.selection[i].contents.substr(0, 39);  // otherwise name it with the first 40 char of the contents
                  }  
                  app.selection[i].createOutline();  // then create outlines from the text
                  app.selection[i].name = newName;  //  name the layer with the text we saved
              }
              

               

              This code selects all the items, then loops through them. At present I will create a file with ONLY the text objects I want to outline, then paste them back into the main document, but at some stage I may adapt the code to outline the text on a specific layer of my main file.

               

              Thanks again!

              openbracket