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

How do I get a text range contents in specific layer only?

Contributor ,
Dec 30, 2020 Dec 30, 2020

Copy link to clipboard

Copied

Currently I have two layers in an AI document.

Layer name = Custom1

Layer name = Custom2

 

In each one of these layers I have a specific text range with the contents

TEST1 and TEST2

 

Custom1 has TEST1 text and Custom2 has TEST2

How do I select the contents of the specific layer?

 

I can select the specific layer like so:

  var aDoc = app.activeDocument;
  aDoc.layers.getByName(layerName);

The only way I can get the text range contents is like so:

aDoc.activeLayer.textFrames[0].textRange.contents

But this is gives me the textFrames from the entire document so [0] in the index gives for the document not the layer.

How can I get the textRange.contents of a specific layer only?

TOPICS
Scripting

Views

237

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

Guide , Dec 30, 2020 Dec 30, 2020

 

var layerz = app.activeDocument.layers;
alert( layerz["Custom1"].textFrames[0].textRange.contents );  // TEST1
alert( layerz["Custom2"].textFrames[0].textRange.contents );  // TEST2

 

Votes

Translate

Translate
Adobe
Guide ,
Dec 30, 2020 Dec 30, 2020

Copy link to clipboard

Copied

 

var layerz = app.activeDocument.layers;
alert( layerz["Custom1"].textFrames[0].textRange.contents );  // TEST1
alert( layerz["Custom2"].textFrames[0].textRange.contents );  // TEST2

 

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 Expert ,
Dec 30, 2020 Dec 30, 2020

Copy link to clipboard

Copied

LATEST
  1. Is TEST1 (or TEST2) the whole (only) contents - or only a part of the contents of the textFrame in your layer?
  2. Are there any other textFrames in the corresponding layers?

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