Copy link to clipboard
Copied
I use grep to search for linked images (~ a) and change the properties on that line, but I want to modify the text properties of the next line (the one highlighted in yellow) or in any case select the first word of the following line.
Thanks in advance.
Hi Brian! 😉
Change:
myFinds[i].paragraphs[0].lines[1].leading = 20;
by:
myFinds[i].lines[0].insertionPoints[-1].lines[0].leading = 20;
or, less greedy (only the first char of the next line):
myFinds[i].lines[0].insertionPoints[-1].lines[0].characters[0].leading = 20;
(^/) The Jedi
Copy link to clipboard
Copied
Use for those paragraphs a style which has not a fixed value, use (auto).
Copy link to clipboard
Copied
Do you have a visible example of what you are saying?
Copy link to clipboard
Copied
Change the leading to (auto) in that paragraph style. Instead of something like 12 pt without paranthesis.
Copy link to clipboard
Copied
I want to edit the following line with parameters that I have in my script, I just need to select it. Same thanks for trying to give a solution, but it is not what I need.
Copy link to clipboard
Copied
Do you expect the next line to always be the second line in the containing paragraph? If so, you can try looping through your finds like this:
for (var i = 0; i < myFinds.length; i++) {
$.writeln(myFinds[i].parent.paragraphs[0].lines[1].contents);
}
If you want the first word, you would append words[0] after lines[1]
Copy link to clipboard
Copied
//CLEAN GREP
app.findGrepPreferences = null;
app.changeGrepPreferences = null;
//find image and replace property of text :
app.findGrepPreferences.findWhat="~a";
app.changeGrepPreferences.leading = 20; //INTERLINEADO
app.changeGrepPreferences.baselineShift = -10;//DEZPLAZAMIENTO VERTICAL
app.changeGrep(true);
// find image and select next line
app.findGrepPreferences = null;
app.changeGrepPreferences = null;
//what grep do i use here?
app.changeGrepPreferences.leading = 20; //INTERLINEADO
app.changeGrep(true);
Copy link to clipboard
Copied
Easier to just do this rather than rely solely on GREP.
app.findGrep returns an array of Character that you can then loop through to find containing paragraph and execute on the lines.
//CLEAN GREP
app.findGrepPreferences = null;
app.changeGrepPreferences = null;
//GET FIND GREP
app.findGrepPreferences.findWhat="~a";
var myFinds = app.findGrep(true);
for (var i = 0; i < myFinds.length; i++) {
try {
myFinds[i].leading = 20;
myFinds[i].baselineShift = -10;
myFinds[i].paragraphs[0].lines[1].leading = 20;
} catch(e) {
continue;
}
}
app.findGrepPreferences = null;
app.changeGrepPreferences = null;
Copy link to clipboard
Copied
Hi Brian! 😉
Change:
myFinds[i].paragraphs[0].lines[1].leading = 20;
by:
myFinds[i].lines[0].insertionPoints[-1].lines[0].leading = 20;
or, less greedy (only the first char of the next line):
myFinds[i].lines[0].insertionPoints[-1].lines[0].characters[0].leading = 20;
(^/) The Jedi
Copy link to clipboard
Copied
Better, sure!
Copy link to clipboard
Copied
Michel__FRIdNGE_ a query, from my GREP search, how can I get the path of these linked images?
Copy link to clipboard
Copied
myFinds[i].pageItems[0].graphics[0].itemLink.filePath;
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more