Skip to main content
tssee
Inspiring
July 24, 2016
Answered

creates level if not present

  • July 24, 2016
  • 2 replies
  • 278 views

Good morning

I am creating a workflow that has to create specific levels

the problem, and that if the level already exists should not create another.

So if the layer with the name exists 123456 must not do anything,

if instead the 123456 level does not exist create it.

According to you, and can do this ?.

This topic has been closed for replies.
Correct answer pixxxelschubser

tssee@imgof.com​,

You can use a try catch clause for this:

var aDoc = app.activeDocument;

try {

    aDoc.layers.getByName ("123456");

    alert ("level alredy exists");

    // do nothing

    }

catch (e) {

    alert ("level does not exists");

    // do whatever you want

    }

Have fun

2 replies

JJMack
Community Expert
Community Expert
July 24, 2016

ould there be more than One 123456 ?

JJMack
pixxxelschubser
Community Expert
pixxxelschubserCommunity ExpertCorrect answer
Community Expert
July 24, 2016

tssee@imgof.com​,

You can use a try catch clause for this:

var aDoc = app.activeDocument;

try {

    aDoc.layers.getByName ("123456");

    alert ("level alredy exists");

    // do nothing

    }

catch (e) {

    alert ("level does not exists");

    // do whatever you want

    }

Have fun