4 Replies Latest reply on Sep 26, 2014 11:19 AM by CarlosCanto

    ScriptUI palette can't access document

    Dirk Becker Level 4



      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 {
        } catch( ex ) {
      var w = new Window("palette","Test",undefined,{ resizeable: true });
      var b = w.add("button",undefined,"Here!");
      b.onClick = helloDocument;


      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,