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

DocumentMode invalid enumeration

Engaged ,
Jun 15, 2018 Jun 15, 2018

I noticed an old script no longer works on CC

  if (app.activeDocument.mode == DocumentMode.INDEXEDCOLOR)

  {

   // blah blah

  }

 

I got the error 1320 Invalid enumeration value, but I'm pretty sure that's valid code. So what's up Photoshop?

Whereas I got round it by evaluating as strings:

  var m = app.activeDocument.mode;

  if (m == "DocumentMode.INDEXEDCOLOR")

  {

   // blah blah

  }

Any ideas?

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

People's Champ , Jun 15, 2018 Jun 15, 2018

Are you sure that the error is in the first line?
Try using try-catch to determine the line number with error.

try {

if (app.activeDocument.mode == DocumentMode.INDEXEDCOLOR) 

  // blah blah 

}

catch (e) { alert("Line: " + e.line + "\n\n" +e); }

Translate
Adobe
Explorer ,
Jun 15, 2018 Jun 15, 2018

Using DocumentMode.INDEXEDCOLOR directly worked fine for me just now on OSX with CC 2018.

What OS and Photoshop version are you using?

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
Explorer ,
Jun 15, 2018 Jun 15, 2018

i cannot reproduce your problem with PS CC 19.1.3

I tried:

if (app.activeDocument.mode==DocumentMode.GRAYSCALE) $.writeln ('GRAY')

if (app.activeDocument.mode==DocumentMode.RGB) $.writeln ('RGB')              // actually correct result

if (app.activeDocument.mode==DocumentMode.INDEXEDCOLOR) $.writeln ('INDEXEDCOLOR')

No idea what's going on with your version

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
People's Champ ,
Jun 15, 2018 Jun 15, 2018

Are you sure that the error is in the first line?
Try using try-catch to determine the line number with error.

try {

if (app.activeDocument.mode == DocumentMode.INDEXEDCOLOR) 

  // blah blah 

}

catch (e) { alert("Line: " + e.line + "\n\n" +e); }

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
Engaged ,
Jun 18, 2018 Jun 18, 2018

Running your script with the try/catch which works. I added two lines, the last of which falls over.

Running Win 7 Photoshop CC 2017.10  20170309.r.207 x 64 I get this:

try { 

if (app.activeDocument.mode == DocumentMode.INDEXEDCOLOR)   

{   

  // blah blah   

}   

catch (e) { alert("Line: " + e.line + "\n\n" +e); } 

 

var m = app.activeDocument.mode;

if (m == DocumentMode.GREYSCALE) alert("Grey"); // error 1320 Invalid enumeration value

 

PS_error.png

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
People's Champ ,
Jun 18, 2018 Jun 18, 2018

GRAYSCALE

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
Engaged ,
Jun 18, 2018 Jun 18, 2018
LATEST

lady jane greyscale *facepalm*

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
LEGEND ,
Jun 17, 2018 Jun 17, 2018

It'd be more apropriate you marked that as correct solution, as that's what you wanted: Multiple point selection in code

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