Skip navigation
Currently Being Moderated

Multiple documents

Feb 20, 2012 1:10 PM

When working with multiple documents, and I switch from the "current" document to another, is there some way I have to notify my plugn that I have a different document, or does my plugin always ASSUME it is working on the "current" document. I ask this in conjunction with Dictionarys, as when I switch documents, I cannot access what I think is the dictionary for the current document. Is there some type of document-dictionary relationship I am missing ?

 
Replies
  • Currently Being Moderated
    Feb 21, 2012 7:25 AM   in reply to swisnies256

    I'm not sure what you're asking for. There are notifiers that let you know when the current document changes. You can get the handle to the current document as well, which is a good way to know which document you're 'currently' talking to. You can't talk to the dictionaries of a document is current, maybe that's what you're asking?

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2012 10:19 AM   in reply to swisnies256

    It depends on where you're getting the dictionary. There are actually several places to get dictionaries, and you can even create your own (which is sort of necessary, since you can have entries in dictionaries that are themselves dictionaries!). Art objects, layers, they also have dictionaries. Live Effects have them, and a few other special cases have them too (some of the advanced stroke options).

     

    If you're using AIDocumentSuite::GetDictionary() -- as I suspect you are -- then, yes, that's document specific. That means that you can't keep writing out to the same dicitonary if the user switches documents. Getting the document's dictionary is pretty cheap though; if you're hanging on to that handle one simple solution is just get it fresh every time you want to talk to the dictionary. That way you won't get complaints when the current document switches. If you try and talk to objects from a document when another one is 'current', you'll almost always get errors.

     

    That said, if you're doing something that invovles the current document's dictionary and it involves a panel, you'll definitely want to react to the document changed notifier! Our product has several panels, and they interact with dictionaries all the time. Keeping the panels updated when the document changes is one of the important tasks of any panel (usually!). You'll be interested in: kAIDocumentChangedNotifier, kAIDocumentOpenedNotifier & kAIDocumentClosedNotifier.

     

    Also, the sample code isn't a great place for explanations. I'd go to the actual suite headers, which aren't bad for documentation. AIDocument.h has this:

     

        /** Retrieves the recorded dictionary associated with the current document.

            Changes in this dictionary and its contents are recorded in the undo history.

     

            Dictionaries are reference counted. You must call \c #AIDictionarySuite::Release()

            when you no longer need the reference.

                @param dictionary [out] A buffer in which to return a pointer to

                    the dictionary reference.

                @see \c #GetNonRecordedDictionary()

            */

        AIAPI AIErr (*GetDictionary) ( struct _AIDictionary** dictionary );

     
    |
    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