Copy link to clipboard
Copied
How do I select the graph of my GREP search?
GREP only selects the text space of the image, but I need to select the graphic that is within that space (.eps).
Moises -- You rarely need to select anything in scripting, and you should avoid it as much as possible because selections aren't stable and often behave in unexpected ways.
~a finds characters, which you can check in the ESTK's debugger (or whatever you use). Characters can have rectangles, and rectangles can contain images. So this:
myFinds[i].rectangles[0].images[0]
gets you the image. But you want to get the image's file path, which you can get only through its link:
myFinds[i].rectangles[0].
...
Copy link to clipboard
Copied
I think you are trying to select it with the wrong tool.
Try:
var links = app.activeDocument.links;
Then you can loop through each link and do anything you need with it.
for (var i = 0; i < links.length; i++) {
alert("The file path is " + links[i].filePath);
}
Copy link to clipboard
Copied
Hello Friend, but I want to select the graph as if it were the selection tool.
Copy link to clipboard
Copied
Moises -- You rarely need to select anything in scripting, and you should avoid it as much as possible because selections aren't stable and often behave in unexpected ways.
~a finds characters, which you can check in the ESTK's debugger (or whatever you use). Characters can have rectangles, and rectangles can contain images. So this:
myFinds[i].rectangles[0].images[0]
gets you the image. But you want to get the image's file path, which you can get only through its link:
myFinds[i].rectangles[0].images[0].itemLink.filePath
and now you can open and read the contents of the EPS image.
This is a very roundabout and time-consuming way of doing things. Yalda is right: it's much simpler to go through the links collection.
P.
Copy link to clipboard
Copied
app.findGrepPreferences = null;app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat="~a"; ///FIND image
var myFinds = app.findGrep();
app.findGrepPreferences = null;app.changeGrepPreferences = null;
for (var i = 0; i < myFinds.length; i++) {
var rectan=myFinds[i].rectangles[0].allGraphics[0];
var path_file =rectan.itemLink.filePath;
alert(path_file);
}
Thank you Mr. Peter, with your explanation I found another way without using ".select ()".