Getting access to app.activeDocument

was written by M.O.Z.G, August 28, 2014 - Tags: , , , , , , , , , - Category: Blog

During the development of the next script for Illustrator, faced with a very interesting behavior. In my case, one of the active palette called a helper dialog boxes that have just had to initiate work with the active document, based on the input of these data. Then I noticed that the dialog boxes can't receive / send data to the active document. During the search such problems and their solutions, I realized that should to think in the direction of BridgeTalk, declaring the target application. Scripts called in this way worked well, but were nuances. Firstly the script should be placed in quotes, with all its consequences, and variables are declared after the call, don't read
Solution turned out to be pretty simple, but not obvious - instead of calling individual commands through BridgeTalk, one only has to call the dialog window. That allows him and all functions called from, refer to the document, not breaking the usual style of coding.

For clarity, "two-button" version of the script that demonstrates the problem. Can try to make a call not through btExecute, and you will see that it will not work.

I write mostly for myself, but if there's valuable insights on the subject - it is not forbidden)

If you found an error, highlight it and press Shift + Enter or click here to inform us.

Leave a Reply

Your email address will not be published. Required fields are marked *