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

ScriptUI palette can't access document

$
0
0

Hi,

 

I've recently started Illustrator scripting for my own purposes, but it is sometimes difficult to transfer InDesign knowledge.

Could anybody please tell me what's wrong with the following trivial script?

 

#target illustrator
#targetengine "main"


function helloDocument() {
  try {    alert(app.activeDocument.name);  } catch( ex ) {    alert(ex);  }
}

var w = new Window("palette","Test",undefined,{ resizeable: true });
var b = w.add("button",undefined,"Here!");
b.onClick = helloDocument;
w.show();

 

In InDesign the targetengine "main" would be a no-go, because it is the only transient engine - variables are gone after run. Even though the "JavaScript Tools Guide CC" still describes the targetengine directive as supported by Illustrator CS5(!), I did not find a way to create an own targetengine. The "main" engine appears to work persistent in Illustrator - as mentioned in another thread. Even though I'd prefer an own playing ground, I can live with that failure for now.

 

Anyway, my actual problem is that the active document is not accessible from the button click handler. The palette window shows up and a click invokes the handler, but all I get is an exception "there is no document". When I change the "palette" to "dialog", the otherwise unmodified script works.

 

Thanks for any clues,

Dirk


Viewing all articles
Browse latest Browse all 12845

Trending Articles



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