Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

How to access app.activeDocument from a palette button?

$
0
0

I'm trying to debug a script that silently fails (I've got a seperate "How best to debug?" question 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 threads linking to things referring to "The holy grail of Illustrator scripting", lots of "You can't" comments, something I didn't understand about refreshing the connection to the app, something about #targetengine another 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?


Viewing all articles
Browse latest Browse all 12845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>