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

[Javascript] Getting app.executeMenuCommand("doc-color-cmyk") to work within a larger script

Community Beginner ,
Jul 30, 2021 Jul 30, 2021

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 ]

 

TOPICS
Print and publish , Scripting

Views

260

Translate

Translate

Report

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
Adobe
Community Expert ,
Jul 30, 2021 Jul 30, 2021

Copy link to clipboard

Copied

You could try adding

$.sleep(1000); // 1000 milliseconds

after the menu command.

 

Votes

Translate

Translate

Report

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
Community Beginner ,
Jul 30, 2021 Jul 30, 2021

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.

Votes

Translate

Translate

Report

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
New Here ,
Apr 23, 2024 Apr 23, 2024

Copy link to clipboard

Copied

LATEST

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 

Votes

Translate

Translate

Report

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