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

Execute events if the document has a certain width or not

Contributor ,
Sep 08, 2017 Sep 08, 2017

Hello friends! We need to get a script that verifies if the active document has a width of 210 mm:

If this is true = Run "task 1"

If this is false = Run "task 2"

Thank you

TOPICS
Actions and scripting
696
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

Advocate , Sep 08, 2017 Sep 08, 2017

Agh, so all it was missing is >= sign then: if greater or equal to 210

if (activeDocument.width >= 210) {

    // run task 1

} else {

    // run task 2

}

However, if you want to run task 1 only if document is 210, then this:

if (activeDocument.width === 210) { 

     // run task 1 

} else { 

     // run task 2 

}

It all depends on what you are trying to do there.

Translate
Adobe
Advocate ,
Sep 08, 2017 Sep 08, 2017

if (activeDocument.width > 210) {

     // run task 1

} else {

     // run task 2

}

Like this?

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
Contributor ,
Sep 08, 2017 Sep 08, 2017

Hi Tomas Sinkunas even with a 210mm wide document, it indicates as task 2.

if I edit the script for: if (activeDocument.width = 210) indicates as task 1. independent of size.

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
Advocate ,
Sep 08, 2017 Sep 08, 2017

Agh, so all it was missing is >= sign then: if greater or equal to 210

if (activeDocument.width >= 210) {

    // run task 1

} else {

    // run task 2

}

However, if you want to run task 1 only if document is 210, then this:

if (activeDocument.width === 210) { 

     // run task 1 

} else { 

     // run task 2 

}

It all depends on what you are trying to do there.

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
Contributor ,
Sep 08, 2017 Sep 08, 2017

It worked very well now! Thank you very much for the fast and efficient support Tomas Sinkunas

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
Advocate ,
Sep 08, 2017 Sep 08, 2017
LATEST

Sure thing buddy.

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