2 Replies Latest reply on Apr 1, 2013 10:17 AM by panduvittala

    AIUID save in dictionary

    panduvittala Newcomer

      AIUIDRef uidref=GetUID(GetArt(range));

      sAIDocument->GetDictionary(&dictRef);

      if(dictRef)      {

           AIEntryRef entryref=sAIEntry->FromUID(uidref);

           AIDictKey dictkey = sAIDictionary->Key("mykey");

           sAIDictionary->Set(dictRef, dictkey, entryref);

      }

       

       

      This is the code I am using to save the uid in dictionary. The code executes. Not sure if it saves uid or not. But illustrator crashes when document is closed. Any idea what is wrong?  Thanks in advance.

        • 1. Re: AIUID save in dictionary
          A. Patterson Champion

          I think you're missing a step, here's what I'm doing:

           

          SetArtUIDValue(AIDIctionaryRef dictionary, const char* entryName, AIUIDRef uid)

          {

               AIEntryRef entry = 0;

           

               try {

                    AIUIDREFRef uidRef = 0;

                    AIErr error = sUID->NewUIDREF(uid, &uidRef);

                    if (kNoErr != error) throw ai::Error(error);

           

                    AIEntry entry = sEntry->FromUIDREF(uidRef);

                    AIDictKey key = sDictionary->Key(entryName);

           

                    error = sDictionary->Set(dictionary, key, entry);

                    if (kNoErr != error) throw ai::Error(error);

               } catch (...) {

                    if (entry) {

                         sEntry->Release(entry);

                    }

                    throw;

               }

           

               sEntry->Release(entry); // never forget to do this or you leak memory!

          }

          • 2. Re: AIUID save in dictionary
            panduvittala Newcomer

            Thanks, that worked.