• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Retain layer names when outlining text

Community Beginner ,
May 07, 2016 May 07, 2016

Copy link to clipboard

Copied

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?

TOPICS
Scripting

Views

662

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 07, 2016 May 07, 2016

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].con

...

Votes

Translate

Translate
Adobe
Community Expert ,
May 07, 2016 May 07, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 07, 2016 May 07, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 09, 2016 Jun 09, 2016

Copy link to clipboard

Copied

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.characters.length < 40) { // if the name is less than 40 char

        var newName = app.selection.contents; // name it with the contents

    } else { 

        newName = app.selection.contents.substr(0, 39);  // otherwise name it with the first 40 char of the contents

    } 

    app.selection.createOutline();  // then create outlines from the text

    app.selection.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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 20, 2024 Mar 20, 2024

Copy link to clipboard

Copied

LATEST

Hi @pixxxelschubser When creating a text from Illustrator. It will be creating a new layer with same name as the text. But whenever we change the text content then layer name changed accordingly. Can we keep layer name when changing the text content? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines