Skip to main content
Inspiring
December 6, 2017
Answered

Convert colors to RGB

  • December 6, 2017
  • 1 reply
  • 2715 views

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

This topic has been closed for replies.
Correct answer LeoTaro

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?


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

1 reply

Inspiring
December 6, 2017

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.

Inspiring
December 7, 2017

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?

Inspiring
December 7, 2017

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.