Which event causes this code to be called? You may need to set the AppContext if it is not called directly from a plugin message.
It is called from the method:
ASErr TrackToolCursor(AIToolMessage* message)
(this method is called from the Plugin.cpp base class, from the Message method, kSelectorAITrackToolCursor event)
In this method, I check which tool is selected, and then I perform a "CheckForArtHit" (a little bit as in the Annotator sample).
I tried to add before the call of the CheckForArtHit method:
But I still have the exception...
In the output window, it's displayed as:
Exception thrown at 0x00007FFED5D9A1C8 in Illustrator.exe: Microsoft C++ exception: ai::Error at memory location 0x000000000014CE48.
Which is causing the PARM exception I suppose...
Then, I use this hitRef to get a patch:
- ai::int32 part = sAIMeshHit->GetPart(hitRef);
- AIMeshPatchIterator meshPatchIterator;
- result = sAIMeshHit->GetPatch(hitRef, &meshPatchIterator);
Line 01 seems to work, but line 04 returns me a PARM error.
So you get a sensible value in part?
Have you tried setting meshPatchIterator to NULL before calling GetPatch? As meshPatchIterator is reference counted, it is possible that if you pass in a non NULL value it is trying to do a Release on it.
Yes, I tried, but that give the exact same result. If I avoid the return error code, and I try to continue, an exception is raised when I leave the method (maybe during the meshPatchIterator release). The value of this iterator is not null, but I think it points in a weird place...
Strange fact, if I move this code in a handler of a kSelectorAIDrawAnnotation message, everything goes fine!!!!
I don't understand why, but I have a workaround...
ASErr BoegliMesherPlugin::Message(char* caller, char* selector, void* message)
ASErr result = kNoErr;
result = Plugin::Message(caller, selector, message);
if (result == kUnhandledMsgErr)
if (strcmp(caller, kCallerAIAnnotation) == 0)
if (strcmp(selector, kSelectorAIDrawAnnotation) == 0)
.... Here it works!!!!
I found... My bad!!!!
The hitRef was released few lines before... I just move the call to the release after, and everything seems fine!
Thanks LeoTaro for your help...