Skip to main content
Known Participant
May 28, 2013
Answered

Help! new to script

  • May 28, 2013
  • 1 reply
  • 1546 views

hi forum!......

I m new to scripting...

I want a small things to do with scripting.

I want to select an image (link) placed inside page(0) of document.

my link name. teddy_1.ai. and the location is in desktop (PC);

so....

app.select("~/Desktop/teddy_1.ai");

sorry i'm just tring....

pls help me forum.....

THANKS,

FST...

This topic has been closed for replies.
Correct answer Jump_Over

Hi,

run this to select image in displayed doc (IF placed and IF so named indeed):

app.activeDocument.links.itemByName("teddy_1.ai").parent.select();

In case of "first" script it should be a list of every graphics file names written in ESTK console. What do you mean "nothing happens'?

To select image is your script's goal?

There is a basic rule on this forum:  >>complex info is a complex help<<

Jarek

1 reply

Inspiring
May 28, 2013

Since you're new to scripting, I'll point you to some helpful resources.

The Adobe InDesign CS6 Object Model is a fantastic reference. You can browse through everything that ExtendScript has to offer. You'll probably want to go through the Adobe InDesign CS6 Scripting Tutorial to get started with scripting. The Adobe InDesign CS6 Scripting Guide: JavaScript and Adobe CS5 JavaScript Tools Guide are also great resources.

It looks like you'll have to actually find the graphic object in the document before you can select it. To help you get started, try running

var graphics = app.activeDocument.Pages[0].allGraphics;

for (var i = 0; i < graphics.length; i++) {

          $.writeln("Name:" + graphics.name);

          $.writeln("Display Name" + (new File(graphics.itemLink.filePath)).displayName);

}

and see if you can find your "teddy_1.ai" image.

If it does have a name, you might be able to use something like:

app.activeDocument.links.itemByName("teddy_1.ai");

There's also a method

app.activeDocument.findObject()

but I'm not sure if you could use it for your purpose.

Good luck!

DriveFSTAuthor
Known Participant
May 29, 2013

Hi din385;

I tried with your above script;

var graphics = app.activeDocument.Pages[0].allGraphics; for (var i = 0; i < graphics.length; i++) {           $.writeln("Name:" + graphics.name);           $.writeln("Display Name" + (new File(graphics.itemLink.filePath)).displayName); }

and also like this...

app.activeDocument.links.itemByName("teddy_1.ai").select();

but nothing happens.

I cound not able to select the image

("teddy_1.ai").

could you please help me directly.....


Jump_Over
Jump_OverCorrect answer
Legend
May 29, 2013

Hi,

run this to select image in displayed doc (IF placed and IF so named indeed):

app.activeDocument.links.itemByName("teddy_1.ai").parent.select();

In case of "first" script it should be a list of every graphics file names written in ESTK console. What do you mean "nothing happens'?

To select image is your script's goal?

There is a basic rule on this forum:  >>complex info is a complex help<<

Jarek