Skip to main content
peter11391697
Participant
March 18, 2015
Answered

How do I loop through selected links?

  • March 18, 2015
  • 1 reply
  • 655 views

Hi!

I'm looking for clues on how to run a script on selected links (selected in the Links window).

Like this sample script that runs an alert when links are missing:

var aDoc = app.activeDocument;

for(var n = 0; n < aDoc.links.length; n++) {

     var aLink = aDoc.links;

     if (aLink.status == LinkStatus.linkMissing) {

          alert(aLink.filePath);

     }

}

Is there something like LinkStatus.linkSelected?

Or some other way for the script to sort out the selected links.

Any input would be extremely appreciated!

Thanks!

/Peter

This topic has been closed for replies.
Correct answer Jump_Over

Hi,

As far as I know - not possible to read selection from Link Panel (any UI Panel).

Other solution?

- to create a dialog with listBox (each list item is a link read from a doc) and "multiselect" property set as "true".

This way user can select a set of links and script can do a job based on selection.

Jarek

1 reply

peter11391697
Participant
March 19, 2015

So, I got a little further. But this script only works with links selected in the documents or the layer tab.

Could anyone point me to how it's done if the link is selected in the links tab?

If its not possible just tell me. Or if you have any other solution I'd be happy to hear that as well.

Current script:

var sel = app.activeDocument.properties.selection;

for(var n = 0; n < sel.length; n++) {

    if(sel == '[object Image]'){

        // Directly selected image

        aLink=sel.itemLink.filePath;

    }

    else{

        // Rectangle selected

        aLink=sel.graphics[0].itemLink.filePath;

    }

alert(aLink);

}

Jump_Over
Jump_OverCorrect answer
Legend
March 19, 2015

Hi,

As far as I know - not possible to read selection from Link Panel (any UI Panel).

Other solution?

- to create a dialog with listBox (each list item is a link read from a doc) and "multiselect" property set as "true".

This way user can select a set of links and script can do a job based on selection.

Jarek

peter11391697
Participant
March 19, 2015

Thanks for the reply!

I'll look inte the listBox option. That looks like the way to go.

Peter