Copy link to clipboard
Copied
I found the following code through this forum, for setting the document color mode to CMYK:
app.executeMenuCommand("doc-color-cmyk");
It works well for a document I already have open, running the above code as just a little test script.
The problem is, I am trying to run this as part of a larger script that works through a whole folder (The script does things like remove guides, remove stray points, delete empty text nodes, resize the art, etc.) When run like this, the script seems to ignore the line of code to change color mode.
I tried moving the code to the point right after the script opens each file, thinking maybe something later in my code is interfering with it, but with that it gets the same result (no effect on color mode).
Then I tried just removing everything except the parts of the script that open the file, set color mode, and save and close the file. This time it worked.
Also, I tried running the unmodified script on a folder that contained only ONE file. This also worked.
It appears to me almost as if the executeMenuCommand code needs more time to process than "regular" JavaScript commands.
Has anyone run into anything like this or have ideas for how to resolve it?
[ title changed by moderator ]
Copy link to clipboard
Copied
You could try adding
$.sleep(1000); // 1000 milliseconds
after the menu command.
Copy link to clipboard
Copied
Thanks for the suggestion. I may try that later, but for now, the script seems to be working.
I'm not sure what exactly I did to resolve the issue. I did delete some comment lines but I wouldn't think that would have any impact on this. I also restarted Illustrator. Go figure.
If the problem resurfaces, I may try your idea.
Copy link to clipboard
Copied
tldr;
Create a Blank file and then run the script from there.
---------
I had the same issue, adding a time out wont fix it 😞
But opening a a blank file before running the Script will.
Why i dont know but it works xD
found the solution it in this github project: https://github.com/arx-e/pdf-to-cmyk-and-replace-rich-black