I'm trying to debug a script that silently fails (I've got a
here).
Through brute force trial and error I've established that I can't access app.activeDocument in a function called by a button in a palette, and that any attempt to even look at app.activeDocument within the scope of this function causes the script to fall over and fail silently with no errors - even something that should be safe like if (!app.activeDocument){}.
So, how do I access the active document - and specifically, app.activeDocument.selection - from within the scope of a function called by a button on a palette window?
I've looked in the Javascript tools guide, the Illustrator CS6 scripting guide and Peter Kahrell's ScriptUI docs, and found nothing. I've googled around and found worrying long long linking to things referring to , lots of "You can't" comments, something I didn't understand about refreshing the connection to the app, which seems to involve writing a seperate javascript file to the hard disk then running it (?!?!) and something else called BridgeTalk which seems to involve actionscript.
Is it really this complicated? This is literally my first Illustrator script, and all I want is a palette (yes, it has to be a palette, not a dialog) that gets information about the current selection when you press a button.
So, simple question, (hopefully) simple answer! How do you access data about the current selection from a palette button?