Copy link to clipboard
Copied
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?
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); }
Copy link to clipboard
Copied
Using DocumentMode.INDEXEDCOLOR directly worked fine for me just now on OSX with CC 2018.
What OS and Photoshop version are you using?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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); }
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
GRAYSCALE
Copy link to clipboard
Copied
lady jane greyscale *facepalm*
Copy link to clipboard
Copied
It'd be more apropriate you marked that as correct solution, as that's what you wanted: Multiple point selection in code
Find more inspiration, events, and resources on the new Adobe Community
Explore Now