Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Script UI breaks connection with AI Document?

Explorer ,
Jun 15, 2010 Jun 15, 2010

Last week I wrote a simple script that interacts with my document and exports layers as images.

The script works great, but I thought I'd add a nice UI to it before I release it to the world, so I spent last Saturday making the GUI.

Now, I've built my UI, and I hook it up to my existing code.

If I  trace the current "activeDocument" at the beginning of my code, before I instantiate the window, I get what you would expect:

alert("Current Window:"+.app.activeDocument);//  Traces -   Current Window:[Document myTestDoc.ai]

Now if I try to reference my document from the window click handler, or after I've closed my window I get this:

alert("Current Window:"+.app.activeDocument);//  Traces -       Current Window:[Document]

alert("Current Window:"+.app.documents[0]);//  Also Traces -   Current Window:[Document]

The script can still see the document, but suddenly it can't introspect it.

"app.documents" yields the correct number of open documents,

"app.name" yields the correct application "Adobe Illustrator"

but anything like the following will fail.

alert(app.documents[0].layers.length);

Any advice would be massively appreciated.

thanks,

-J

TOPICS
Scripting
10.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Jun 20, 2010 Jun 20, 2010

cool, maybe we find a simple as possible solution.

you don't need the alert, you must set at begin:

#targetengine ????? (I heard "not main" but this seems to be not true, it can be main?)

don't ask me why

#target illustrator
#targetengine another

var btnPnlResource ="panel { orientation:'row', \
text: 'Push Button to Test', \
testBtn: Button { text:'Test' }, \
}";
var dlg = new Window("palette", "Select PATH");
dlg.btnPnl = dlg.add(btnPnlResource);
dlg.show();
dlg.btnPnl.testBtn.onClick = traceDoc;
//alert("M

...
Translate
Adobe
Contributor ,
Jun 29, 2010 Jun 29, 2010

Hi Boys,

your answers are very helpful .

, because thats not what i want to hear . but life is not a "Kindergeburtstag".

so, for the moment i give it up and use a jsx/#target solution.

thank you again for reading and brainstorming and testing.

let my explain more precise the what and why of my shell-experiments.

file.execute() is great but offers not the possibility to pass params.

so i execute a Dos-shell-script (on the fly generated) that calls/starts my target (with params).

Dos-shell-script, because it is very fast.

i use this for example to make a snapshot, save it to the doc-location, with a meaningful name+counter.

in the example above (ps | grep....) the intention is to run illustrator with a script as param (finally triggered by a hot-key).

(Maybe illegal, but on winxp possible)

But only if illustrator is always running.

on windows i create a shortcut for this shell-script and give it a (OS)-hot-key.

(again, dos-shell because of it's speed.)

So, pressing the hot-key will execute the script immediately if illustrator is running.

if not, nothing happens.

To me it seems, if i understand you correct, that the rights-problems makes it impossible to do that with bash on mac.

in detail:

1 not possible to execute a  (on the fly generated)  bash-file

2 not possilbe for the shell to pass a js/jsx to illustrator

cheers

Chris

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 02, 2010 Jul 02, 2010

Hi Chris,

There is interesting file here (on MAC OS X CS4):

/Library/Application support/Adobe/Startup Scripts CS4/Illustrator/illustrator-14.0.jsx

This file is running just after illustrator is loaded & just before it loading pop-up papnel !

I think you can find this file also on PC at (for CS3):

Programs Files/commons files/Adobe/Startup Scripts CS3/Illustrator/illustrator-13.0.jsx

I didn't seen something for older version of illustrator..

Regards, art.chrome

Hmm.. i'm mixed two post, this one and another post about shorcuts.. , So.. may be this one could help for this post, but i will put it also in shortcuts post ..

Message was edited by: artchrome (mistake)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 02, 2010 Jul 02, 2010
LATEST

The script files in the startup folder should be fine they are read for errors at load-up the ones you refer to add functionality to Bridge. They add extra menus etc for Illustrator, Photoshop & Indesign.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 22, 2010 Jun 22, 2010

Cool! Thanks John.

problem is, the estk asks "should I do", and need some time to react.

yes, only except

The Toolkit treats the user's Documents/Adobe Scripts folder, however, as a trusted location; when you double-click a JSX file in that folder, the Toolkit does not display the security alert.

----From JavaScript Tools Guide

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines