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

Testing for Auto Leading and an alert

Community Beginner ,
Mar 25, 2016 Mar 25, 2016

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.

Screen Shot 2016-03-25 at 10.48.00 AM.png

TOPICS
Actions and scripting
407
Translate
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 , Mar 25, 2016 Mar 25, 2016

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.

Translate
Adobe
Community Expert ,
Mar 25, 2016 Mar 25, 2016

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.

Translate
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 ,
Mar 25, 2016 Mar 25, 2016
LATEST

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) + ".")}

Translate
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