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

Ignore script if there is no selection?

LEGEND ,
May 22, 2019 May 22, 2019

How do I write this so AI does not show error messages if nothing is selected?

var aDoc = app.activeDocument;

app.userInteractionLevel.DONTDISPLAYALERTS

var myLayer = "";

//Unite BACK TEXT selection

selection = null;

try {

  (aDoc.layers.getByName("BACK TEXT"));

  var myLayer = aDoc.layers.getByName("BACK TEXT");

  myLayer.hasSelectedArtwork = true;

  app.executeMenuCommand("outline");//AI message: "Can't create type outlines."

  app.doScript("Unite", "AI Actions_KM");//AI message: "The filter produced no results."

} catch (e) {

  //alert here

}

selection = null;

I tried: "app.userInteractionLevel.DONTDISPLAYALERTS" but it had no effect.

Thanks.

TOPICS
Scripting
419
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 , May 22, 2019 May 22, 2019

Sended from phone

if ( app.selection.length > 0 ) {

    alert ("selected");

    }

else {

    alert ("nothing is selected");

    }

Have fun

Translate
Adobe
Community Expert ,
May 22, 2019 May 22, 2019
LATEST

Sended from phone

if ( app.selection.length > 0 ) {

    alert ("selected");

    }

else {

    alert ("nothing is selected");

    }

Have fun

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