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

Convert colors to RGB

Explorer ,
Dec 06, 2017 Dec 06, 2017

Copy link to clipboard

Copied

Hello,

I need to color convert path items stroke/fill in CMYK colorspace to RGB colorspace - essentially the functionality given by Edit > Edit Colors > Convert to RGB.

In my code, I first select the path items. I then invoke the Convert to RGB menu action. However, nothing really happens. The colors stay in CMYK.

The document color mode is RGB.

// Select all paths

error = CollectPaths(&store, &count);

ai::int32 index = 0;

for (index = 0; index < count; index++)

{

     AIArtHandle art = (*store)[index];

     ai::int32 attr;

     error = sAIArt->GetArtUserAttr(art, kArtLocked | kArtHidden, &attr);

     if (!(attr & (kArtLocked | kArtHidden)))

     {

          error = sAIArt->SetArtUserAttr(art, kArtSelected, kArtSelected);

     }

}

// Invoke Convert To RGB

AICommandID convertCmd;

sAICommandManager->GetCommandIDFromName(kColors9CommandStr, &convertCmd);

error = sAIMenu->InvokeMenuAction(convertCmd);

This is what CollectPaths looks like:

ASErr CollectPaths(AIArtHandle ***store, ai::int32 *count)

{

     *store = NULL;

     *count = 0;

     AIMatchingArtSpec specs;

     ai::int16 numSpecs = 1;

     specs.type = kPathArt;

     specs.whichAttr = 0;

     ASErr error = sAIMatchingArt->GetMatchingArt(&specs, numSpecs, store, count);

     return error;

}

Any ideas why the menu action does nothing?

Is it in disabled state because of some reason?

Thanks,

MT

TOPICS
SDK

Views

1.9K

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

correct answers 1 Correct answer

Advocate , Dec 11, 2017 Dec 11, 2017

You could try calling AIUser::AppIdle between the selection code and InvokeMenuAction.

Votes

Translate

Translate
Adobe
Explorer ,
Dec 06, 2017 Dec 06, 2017

Copy link to clipboard

Copied

This seems very similar to the situation as mentioned in [AICS4] Selecting art and making mask does not work together.

It appears that selecting art, and invoking a menu action right after selecting as part of the same message does not work out. May be it requires a menu updation step in between.

Any pointers are welcome.

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
Advocate ,
Dec 07, 2017 Dec 07, 2017

Copy link to clipboard

Copied

When does your code get called, from a plugin message?

Do you deselect the art after invoking the menu command? If not, is the art still selected after your code is called?

I'm not sure if InvokeMenuAction is synchronous or not. Try breaking it down into stages:

1. Just select the art in you code. Is the art selected after calling your code?

2. Select the art and call InvokeMenuAction and don't deselect the art. Are the colors converted?

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
Explorer ,
Dec 07, 2017 Dec 07, 2017

Copy link to clipboard

Copied

Thank you for the ideas Leo.

I'm not de-selecting the art. It stays selected after my code is called.

But the colors aren't converted.

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
Advocate ,
Dec 07, 2017 Dec 07, 2017

Copy link to clipboard

Copied

It seems either the menu item is not picking up the selection or the invoke menu item call is not working. What happens if you select the art before you call your code? What happens if you try to invoke other menu items, say something that pops up a dialog like kColorCommandStr (Edit:Color Settings)?

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
Explorer ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

Thanks Leo for your reply.

Yes, if I select the art manually before I call my code, the color conversion does work.

Also, the ColorSettings dialog popped up when I tried the ColorSettings menu item. These results make me believe that the selection sensitive (enabled/disabled) menu items do not pick the selection, when called back to back after the selection code in response to a message.

Any possible workarounds?

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
Advocate ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

You could try calling AIUser::AppIdle between the selection code and InvokeMenuAction.

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
Explorer ,
Dec 13, 2017 Dec 13, 2017

Copy link to clipboard

Copied

LATEST

Calling AppIdle between selection and invoke menu did the trick !

Thanks for all the help, Leo.

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