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
You could try calling AIUser::AppIdle between the selection code and InvokeMenuAction.
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.
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?
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.
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)?
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?
Copy link to clipboard
Copied
You could try calling AIUser::AppIdle between the selection code and InvokeMenuAction.
Copy link to clipboard
Copied
Calling AppIdle between selection and invoke menu did the trick !
Thanks for all the help, Leo.