Skip navigation
Currently Being Moderated

AIUID save in dictionary

Mar 29, 2013 1:29 PM

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.

 
Replies
  • Currently Being Moderated
    Apr 1, 2013 7:15 AM   in reply to Raghav KR

    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!

    }

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points