Is there a script to combine selected frames as Threaded Text
Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Is there a script to combine selected frames as Threaded Text
- This topic has 15 replies, 4 voices, and was last updated 14 years ago by rydesign.
-
AuthorPosts
-
-
March 19, 2010 at 1:21 pm #55202rydesignMember
I have a layout that I would love to be able to thread and unthread selected items at will just by selecting the frames the text is in and running a script. I basically want to know if anyone knows of a script that functions like the SplitStory script in reverse. It would I have items that move around on the page a lot and would still like to have them threaded in order when I am done moving things around. I have many versions of this layout at different sized and would love just be able to flow the text in to the other layouts with out copying whole frames and moving them about.
Basically the workflow would go…
1. unthread text
2. move objects and their text labels in to their new order
3. select frames and rethread the text.
4. open next layout and paste threaded text in and move objects to match labels
any ideas?
-
March 20, 2010 at 2:46 am #55203Colin FlashmanParticipant
try this link:
https://ajarproductions.com/blo…..-indesign/
or if that link fails, type MergeTextframes_ID into google. should take you to ajarproductions, where the script which does exactly what you want is.
don't forget to thank the author of the script
colly
-
March 22, 2010 at 3:35 am #55207rydesignMember
Well close… but not quite. This merges several frames in to one frame. I still would like all the frames to remain separate threaded text frame. I could use this to merge all the frames then copy all the text and then manually reflow it. It takes one step out of the process but i really would like to find something a bit easier.
-
March 22, 2010 at 4:15 am #55209Theunis De JongMember
Here is a script, specially written for you! It links any two text frames (obviously, only if they are not already linked) in top-down left-right order.
Make sure each frame ends with a hard return, or preferably even a Break Frame character!
if (app.selection.length == 2)
{
a = app.selection[0];
b = app.selection[1];
if (a instanceof TextFrame && b instanceof TextFrame)
{
if (a.geometricBounds[0] > b.geometricBounds[0])
{
a = app.selection[1];
b = app.selection[0];
} else
if (a.geometricBounds[0] == b.geometricBounds[0] && a.geometricBounds[1] > b.geometricBounds[1])
{
a = app.selection[1];
b = app.selection[0];
}
if (a.nextTextFrame == null && b.previousTextFrame == null)
a.nextTextFrame = b;
else
alert (“Oops …”);
} else
alert (“Oops …”);
} else
alert (“Please select two text frames”); -
March 22, 2010 at 5:00 am #55211rydesignMember
Very Awesome… I can't thank you enough. I must say you are one of the most helpful and active InDesign Secrets gurus on the forums. Thank you again. At the risk of looking a gift horse in the mouth is there a way to make it apply to more than 2 frames? Say starting with the top left most frame and ending with the bottom right most frame?
Just wondering
This is helpful enough and works pretty quickly.
I am impressed with how fast you pulled this off in the first place. Thank you agian and agian.
-
March 22, 2010 at 5:35 am #55215Theunis De JongMember
Hey, no prob. I enjoy solving little problems like this
Try this one for size. Select any amount of unlinked (!) text frames in any screen order, and they'll get linked, top to bottom, left to right. The script will not mess up any existing linked frames, even if some are already linked — it'll skip these and link to their first/last frames instead:
var combineMe = new Array;
for (a=0; a<app.selection.length; a++)
{
if (app.selection[a] instanceof TextFrame)
combineMe.push(app.selection[a]);
}
combineMe.sort (function (a,b) { return (a.geometricBounds[0] < b.geometricBounds[0]) || (a.geometricBounds[0] == b.geometricBounds[0] && a.geometricBounds[1] < b.geometricBounds[1]) ? -1 : 1; } );
for (a=0; a<combineMe.length-1; a++)
{
if (combineMe[a].nextTextFrame == null)
{
nextFree = a+1;
while (nextFree < combineMe.length && combineMe[nextFree].previousTextFrame != null)
nextFree++;
if (nextFree < combineMe.length)
combineMe[a].nextTextFrame = combineMe[nextFree];
}
}(Ed.: Forum didn't like font changes :-P Restored to normality — I hope)
-
March 22, 2010 at 6:03 am #55216rydesignMember
This is great! It doens't link the frames in a normal order on my page for some reason. I am trying ot figure out if I can narrow down why.
-
March 22, 2010 at 6:23 am #55217Theunis De JongMember
Hmmm … Testing, it appears to do exactly what I was intending: frames get linked top to bottom, and if the tops are equal, left to right. Can you switch on “Show Text Threads” and check if that's correct?
Remember: it doesn't destroy any existing links, so that's why you might get something you didn't expect — see also my image above.
Under normal circumstances, this is the result of linked six frames that are perfectly aligned:
-
March 22, 2010 at 6:44 am #55218rydesignMember
When I test it with empty new frames it seems to work fine… but just not on my existing text. Hmm not sure. I could send you my text boxes if you want to try and debug. I can't really figure it out.
-
March 22, 2010 at 8:18 am #55220Theunis De JongMember
… Make sure each frame ends with a hard return, or preferably even a Break Frame character … Perhaps that's what's messing your frames up …
If it is, I might be able to insert Frame Breaks where needed with the script.
-
March 22, 2010 at 9:43 am #55221rydesignMember
Awesome Break Frame character works like a champ. I Thank you once more. I certainly hope I am not the only one who finds this extremly useful. Man I need to learn how to script.
-
March 22, 2010 at 1:49 pm #55223Theunis De JongMember
Good! — One thing left to do, here is a version that changes the last hard return into a Frame Break, or in case there is no return, adds the break.
Man I need to learn how to script.
Why not have a go thinking of something you'd like to script and see how far you get? The JS Guide over at Adobe's (InDesign section, “Scripting Stuff” button) has a lot of snippets for common tasks, so you can cut 'n' paste entire sections to make something new. And there always is the Adobe Scripting forum for the odd question left.
Anyway, here is the amended script. The changed section is around the “combine me with next” clause.
var combineMe = new Array;
for (a=0; a<app.selection.length; a++)
{
if (app.selection[a] instanceof TextFrame)
combineMe.push(app.selection[a]);
}
combineMe.sort (function (a,b) { return (a.geometricBounds[0] < b.geometricBounds[0]) || (a.geometricBounds[0] == b.geometricBounds[0] && a.geometricBounds[1] < b.geometricBounds[1]) ? -1 : 1; } );for (a=0; a<combineMe.length-1; a++)
{
if (combineMe[a].nextTextFrame == null)
{
nextFree = a+1;
while (nextFree < combineMe.length && combineMe[nextFree].previousTextFrame != null)
nextFree++;
if (nextFree < combineMe.length)
{
// Add Frame Break when needed:
if (combineMe[a].characters[-1].contents != SpecialCharacters.FRAME_BREAK)
{
if (combineMe[a].characters[-1].contents == “r”)
combineMe[a].characters[-1].contents = SpecialCharacters.FRAME_BREAK;
else
combineMe[a].insertionPoints[-1].contents = SpecialCharacters.FRAME_BREAK;
}
combineMe[a].nextTextFrame = combineMe[nextFree];
}
}
} -
March 23, 2010 at 5:29 am #55233rydesignMember
Whew… It is going to take a bit of work but I think it is the next logical step in my professional development. The script works great. One word of caution to anyone who may use this script in the future.
the latest version will only work if you have text in all the frames you are linking. I have saved this version out as a seperate file.
If you are making a layout and want to select all the frames on a page to link to eachother before you enter text use the script from Jongware's 5:35am post.
now all we need is a name… hahaha
How's ThreadTextEmpty
ThreadTextFilled
-
March 23, 2010 at 8:47 am #55240Theunis De JongMember
.. the latest version will only work if you have text in all the frames you are linking.
Good catch — I did think of making a separate test for it but actually did not because I didn't think you would do that, as I thought there would be no point in linking an empty frame in the middle of a thread …
If I can find some more time, I might look into it (no promise …).
-
March 27, 2010 at 6:10 pm #55344HarbsMember
It looks like you're looking for TextStitch…
-
March 30, 2010 at 5:35 am #55355rydesignMember
Wow… Yeah that works amazingly well and includes all pages. I preferred being able to thread selected frames but my work around to this is just to put the selected frames on their own layer, turn all other layer visibility off, and then run the script. Thank you much Harbs.
-
-
AuthorPosts
- You must be logged in to reply to this topic.