Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

A script for replacing texts only in selected layer?

$
0
0

Hi all,

I have an illustrator document which has many text layers. I have found the script below that replace a text with another one in the document;

 

var doc = app.activeDocument;

var myTextFrames = doc.textFrames;

 

for (i = 0; i < myTextFrames.length; i++) {

var myTF_ByI = myTextFrames[i];

var str = myTF_ByI.contents

var res = str.replace("word1", "word2");

myTF_ByI.contents = res

}


However, there is one problem that the script also replaces the text in other layers even though they are hidden or locked. Could you help me adjust this script to be effective only for the selected or unhidden layer?

 

Cheers,

Akin


Viewing all articles
Browse latest Browse all 12845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>