Copier le lien dans le Presse-papiers
Copié
Hi!
Is there a way to count how many lines of text there are on a paragraph and then add some line breaks if there are not enough lines?
jukka
"count of lines" will give you the number of lines. To add extra lines, just set the contents of the chosen insertion points to newline.
--
Shane Stanley <sstanley@myriad-com.com.au>
AppleScript Pro, April 2010, Florida <http://www.applescriptpro.com>
Copier le lien dans le Presse-papiers
Copié
"count of lines" will give you the number of lines. To add extra lines, just set the contents of the chosen insertion points to newline.
--
Shane Stanley <sstanley@myriad-com.com.au>
AppleScript Pro, April 2010, Florida <http://www.applescriptpro.com>
Copier le lien dans le Presse-papiers
Copié
Thanks Shane!
It was right under my nose, i must be blind!
jukka
Copier le lien dans le Presse-papiers
Copié
Another problem.
I found all the paragraphs that i need, i get the number of lines and if the count of lines is not enough i'll insert returns to the end of paragraph with this loop:
repeat with j from 1 to (11 - theNum)
set contents of insertion point -1 of theParagraph to return
end repeat
This works great with first found paragraph but following paragraphs insertion point -1 is not at the end of paragraph.
Baffled...
Copier le lien dans le Presse-papiers
Copié
Try going backwards through the array
repeat with j from (11-theNum) to 1 by -1
Copier le lien dans le Presse-papiers
Copié
Thanks Larry but no help.
The insert point is still off after first occurence.
jukka
Copier le lien dans le Presse-papiers
Copié
Work backwards, as Larry said, and try insertion point -2 (ie, before the existing return).
Copier le lien dans le Presse-papiers
Copié
Backwards didn´t help
The amount of drifting from -1 is some how related how many returns are added in the previous turn. If the j loop adds 3 returns then the next (i loop, kappale (i)) paragaphs -1 is 3 chars wrong...
Here some code
--befofre this code gets all stylenames -> theStyle
set theJuttu to object reference of selection
tell active document
if theStyle is not "false" then
set theKappaleet to find text of theJuttu
repeat with i from 1 to count of theKappaleet
set kappale to item i of theKappaleet
set theNum to count of every line in kappale
if theNum < 12 then
repeat with j from 1 to (11 - theNum)
set contents of insertion point -1 of kappale to return & return & return & return
end repeat
end if
end repeat
end if
end tell
I´m not an expert on applescripting indesign so if you have better way doing this then i'm all ears...
Just lookin for a help so i dont have to do this by hand for a 14000+ items.
jukka
Copier le lien dans le Presse-papiers
Copié
Sorry, the j loop was a test.
Here's right one
repeat with j from 1 to (11 - theNum)
set contents of insertion point -1 of kappale to return
end repeat
Copier le lien dans le Presse-papiers
Copié
Also, for what it´s worth:
The paragraph that i'm trying to manipulate has an picture frame as first character and the paragraph also has an Drop cap.
---------- tex text tex text tex text
| | tex text tex text tex text
| | tex text tex.
| |
----------
As in this example this paragraph is 2 lines short of what is needed
jukka
Copier le lien dans le Presse-papiers
Copié
> Backwards didn´t help
It will if you actually do it:
repeat with i from (count of theKappaleet) to 1 by -1
--
Shane Stanley <sstanley@myriad-com.com.au>
AppleScript Pro, April 2010, Florida <http://www.applescriptpro.com>
Copier le lien dans le Presse-papiers
Copié
Holly smoke, it works!
I was a bit dazed and confused with the i-loop and j-loop but now i got it working.
Thank you Shane and Larry for sorting this for me. Just did it and it took 11 minutes to do it's magic, by hand it would took me fo 1,5 woking days!
The best part is that i can use it again with my future projects.
Is there any explanation why the loop works backwards?
Do you have any book suggestions for scripting indesign? I have Shirley W. Hopkins book for CS but it's a bit outdated...
Thanks again!
jukka
Copier le lien dans le Presse-papiers
Copié
Hmm... sometimes
set theNum to count of every line in kappale
returns wrong number of lines.
Got to get into that later.
jukka
Copier le lien dans le Presse-papiers
Copié
If you go forward through an array it can mess up the index numbers of the contents. By working backwards, the index numbers are not changed. As to the wrong number of lines, it may be that there is an extra return in the original text.
Copier le lien dans le Presse-papiers
Copié
Ok, got it.
But if theres an extra return, wouldn´t that count as a paragraph?
Trouvez plus d’idées, d’événements et de ressources dans la nouvelle communauté Adobe
Explorer maintenant