Skip to main content
Participant
August 27, 2014
Answered

Problem creating/accesing a document dictionary

  • August 27, 2014
  • 1 reply
  • 764 views

I have problems creating and accessing a document dictionary.

I create a new docuemnt using  the NEW item in the Illustrator menu.

Then I execute the following code through my plugin. I does not work. That is I a unable to retrieve any value fro the dictionary . Actually I am not even sure I wrote anything in the  dictionary.

Is there anything wrong in my code ?

thanks.

{    

    AIDictionaryRef dictionary =NULL ;

    AIErr error = 0;

    error= sAIDocument->GetDictionary ( &dictionary );

   

    

    AIDictKey KEY = sAIDictionary->Key( "MY_Key" );

    string mykey= "2";

    error = 0;

        error= sAIDictionary->SetStringEntry ( dictionary, KEY , mykey.c_str());

     

    AIErr error = 0;

    error= sAIDocument->GetDictionary ( &dictionary );

    const char* Namevalue ;

    error = sAIDictionary->GetStringEntry(dictionary, KEY, &Namevalue);   

    sAIDictionary->Release (dictionary);

   

}

This topic has been closed for replies.
Correct answer Blyskawica

If the first error is 1146045247 ("DOC?") and you get a NULL dictionary, anything further is not going to work.

Depending on where you are executing this code (for example, in response to a panel item click), yes, you may well need to get the AppContext first.

1 reply

A. Patterson
Inspiring
August 27, 2014

Nothing jumps out at me immediately -- what does the error code look like at various stages? That can tell you quite a bit sometimes.

CopymgtAuthor
Participant
August 27, 2014

When I first try to Get the dictionary I get an error 1146045247 and &ictionary is NULL.

I still try to SetStringEntry, and the error there is 1346458189

Is there other stuff I need to do , like getting a context ?

Dos every document/file have a dictionary by default?

Thanks

BlyskawicaCorrect answer
Participating Frequently
August 27, 2014

If the first error is 1146045247 ("DOC?") and you get a NULL dictionary, anything further is not going to work.

Depending on where you are executing this code (for example, in response to a panel item click), yes, you may well need to get the AppContext first.