Hi All
I"m trying to search my document of threaded text frames for sections of paragraph styled bullet points.
Depending on the line count of the bullets I’d then like to add a number of lines to make a consistent number of lines for each section.
Example 1 - finds 6 lines (the first 3 bullets extend to 6 lines when text wrapped), so adds lines 7-10
¢ Comprising check valve, strainers, isolators and flushing/test point
¢ Supplied complete with 4 in 1 inlet fittings
¢ Supplied complete with 4 in 1 inlet fittings
¢ 7
¢ 8
¢ 9
¢ 10
Example 2 - finds 4 lines (the first 2 bullets extend to 4 lines when text wrapped), so adds lines 5-10
¢ Supplied complete with 4 in 1 inlet fittings
¢ Supplied complete with 4 in 1 inlet fittings
¢ 5
¢ 6
¢ 7
¢ 8
¢ 9
¢ 10
So far I have this but I’m getting lost.
tell application "Adobe InDesign CC 2014"
set applied paragraph style of find text preferences to "Product Bullets"
tell document 1
set MyFoundWords to find text
repeat with i from 1 to count of MyFoundWords
set item i of MyFoundWords to contents of item i of MyFoundWords
end repeat
count of paragraphs of text from character 1 of parent story of MyFoundWords to character 1 of MyFoundWords
end tell
end tell
I’ve uploaded my test files and a screen shot here.
http://we.tl/6dWNuZ51MX
many thanks
Shane
Hi. I think you wrote that whole loop as a text coercion, but that can be done more simply. Find text’s result is an object reference in list form; just use the first item and coerce it. The text target should be lines.
set lineGoal to 10
tell application "Adobe InDesign CS3"
set find text preferences's applied paragraph style to "Product Bullets"
tell document 1
set isFound to find text
repeat (lineGoal - (count (isFound's item 1's lines))) times
set isFound's item 1's end to "¢ " & return
end repeat
end tell
end tell
Hi Marc
Thanks for your reply.
I can see where you’re going with this, however I’m getting an error with the script.
error “Can’t get item 1 of {}.” number -1728 from item 1 of {}
I’ve had a play but can’t get it to work.
many thanks
Shane
The empty brackets indicate that nothing is found. My example assumes that there is text that meets the conditions outlined in your question. I tested it, and it works, however, I made no effort at error trapping or making it handle multiple paragraph groups. You should be able to make those adjustments after reading it and observing the event log.
Hi All
This is my final script, I’m sure I’m still going to long way around but hey, it works 
i ended up finding all the sets of bullets via grep and a para style, I then converted each of these in to the actual text found and then searched for the text (rather than the grep) I then added the extra blanklines to the found text.
Thanks again to Marc for pointing me in the right direction.
set lineGoal to 8
set myFoundWordTextStringList to {}
--
tell application "Adobe InDesign CC 2014"
activate
set find text preferences to nothing
set change text preferences to nothing
--
--
set find grep preferences's applied paragraph style to "Product Bullets"
set find what of find grep preferences to "(.+\\r?)+"
--
set MyFoundWords to find grep
set MyFoundWordsList to MyFoundWords
-- make a list of text not reference number, then we'll use this to search again, but on the text not grep
--
repeat with x from 1 to count MyFoundWordsList
set the end of myFoundWordTextStringList to contents of item x of MyFoundWords
end repeat
--
-- Now try and select the text
--
repeat with i from 1 to count of myFoundWordTextStringList
set find text preferences to nothing
set change text preferences to nothing
--
set find what of find text preferences to item i of myFoundWordTextStringList
set selection to find text
-- add blanklines up to linegoal
set linecounts to count of every line of selection
display dialog "Total lines in selected story: " & linecounts giving up after 2
--
-- now add extra line to make up to 10
--
repeat (lineGoal - linecounts) times
set selection's end to "Blankline" & return
end repeat
end repeat
--
end tell