Copy link to clipboard
Copied
Hey everybody.
I would like to test with a script if a text layer is using Auto Leading and display an alert if it is not set to auto.
This is what I have now:
var doc = activeDocument
var lay = doc.activeLayer
var textSize = lay.textItem.size
var textlayer = doc.activeLayer
if (lay.textItem.autoLeading = "false"){
alert("Leading is set to a custom value of "+(activeDocument.activeLayer.textItem.leading) + ".")}
This works when something is set to a specific leading. But when it is set to Auto Leading I get this error.
So I know my "IF" or "VAR" needs to be reworked (probably the alert too just to clean it up), but I have run out of ideas.
First off, you need to set you if statement with a double equal sign "==", otherwise you're setting laytextItem.autoLeading to false. Use a try catch block. if it throws an error, then you know there is auto leading.
Copy link to clipboard
Copied
First off, you need to set you if statement with a double equal sign "==", otherwise you're setting laytextItem.autoLeading to false. Use a try catch block. if it throws an error, then you know there is auto leading.
Copy link to clipboard
Copied
Thank you, Chuck. Always a huge help.
I changed the conditional to:
if (lay.textItem.useAutoLeading == false){
alert("Leading is set to a custom value of "+(activeDocument.activeLayer.textItem.leading) + ".")}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now