5 Replies Latest reply on Oct 7, 2015 6:53 AM by LeGlutz

    sAIMeshHit->GetPatch PARM Exception

    LeGlutz

      Hi,

       

      I have an error code PARM (1346458189) when I try to get a patch from a hit using the MeshHitSuite.

      I'm using Adobe Illustrator CC 2015 SDK.


      First I check if my cursor is over any art (as in Annotator sample):

      AIHitRef hitRef = NULL;
      result = sAIHitTest->HitTest(NULL, &fCursorArtPoint, kAllHitRequest, &hitRef);
      aisdk::check_ai_error(result);
      

             

      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.

       

      Do I miss something?

       

      Thanks

        • 1. Re: sAIMeshHit->GetPatch PARM Exception
          LeoTaro Level 4

          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.

          • 2. Re: sAIMeshHit->GetPatch PARM Exception
            LeGlutz Level 1

            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:

            AppContext appContext(message->d.self);
            
            

            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...

            • 3. Re: sAIMeshHit->GetPatch PARM Exception
              LeoTaro Level 4

                   

              Then, I use this hitRef to get a patch:

              1. ai::int32 part = sAIMeshHit->GetPart(hitRef); 
              2.                  
              3. AIMeshPatchIterator meshPatchIterator; 
              4. 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.

              • 4. Re: sAIMeshHit->GetPatch PARM Exception
                LeGlutz Level 1

                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;

                    try

                    {

                        result = Plugin::Message(caller, selector, message);

                        if (result == kUnhandledMsgErr)

                        {

                            if (strcmp(caller, kCallerAIAnnotation) == 0)

                            {

                                if (strcmp(selector, kSelectorAIDrawAnnotation) == 0)

                                {

                                    .... Here it works!!!!

                • 5. Re: sAIMeshHit->GetPatch PARM Exception
                  LeGlutz Level 1

                  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...