0
Contributor
,
/t5/illustrator-discussions/how-do-i-get-a-text-range-contents-in-specific-layer-only/td-p/11716476
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
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
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
Explore related tutorials & articles
Guide
,
/t5/illustrator-discussions/how-do-i-get-a-text-range-contents-in-specific-layer-only/m-p/11716553#M257599
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
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
LATEST
/t5/illustrator-discussions/how-do-i-get-a-text-range-contents-in-specific-layer-only/m-p/11716638#M257603
Dec 30, 2020
Dec 30, 2020
Copy link to clipboard
Copied
- Is TEST1 (or TEST2) the whole (only) contents - or only a part of the contents of the textFrame in your layer?
- Are there any other textFrames in the corresponding layers?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

