Skip to main content
tokuredit
Inspiring
August 8, 2018
Answered

Check the width of the active layer

  • August 8, 2018
  • 1 reply
  • 1053 views

How to check if the width of the active layer is less than 15cm? If this is true to do something, if it is false to do something else. Thank you!

This topic has been closed for replies.
Correct answer Kukurykus

function sTT(v) {return stringIDToTypeID(v)}

function wdh() {

     (ref = new ActionReference()).putEnumerated(sTT('layer'), sTT('ordinal'), sTT('targetEnum'))

     return executeActionGet(ref).getObjectValue(sTT('bounds')).getInteger(sTT('width')) / 118.11 < 15

}

alert((res = wdh()) ? res : res)

1 reply

Kukurykus
KukurykusCorrect answer
Legend
August 8, 2018

function sTT(v) {return stringIDToTypeID(v)}

function wdh() {

     (ref = new ActionReference()).putEnumerated(sTT('layer'), sTT('ordinal'), sTT('targetEnum'))

     return executeActionGet(ref).getObjectValue(sTT('bounds')).getInteger(sTT('width')) / 118.11 < 15

}

alert((res = wdh()) ? res : res)

tokuredit
tokureditAuthor
Inspiring
August 8, 2018

Here he fires the alert from true or false perfectly. Where do I add my codes to both situations? Please, you could just make a little modification:

alert ("your code here if it's true")

alert ("your code here if false")

Thank you!

Kukurykus
Legend
August 8, 2018

res = wdh(); if (res) alert(true) else alert(false)