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

Viewing 15 reply threads
  • Author
    Posts
    • #55202
      rydesign
      Member

      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?

    • #55203
      Colin Flashman
      Participant

      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

    • #55207
      rydesign
      Member

      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.

    • #55209

      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”);

    • #55211
      rydesign
      Member

      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.

    • #55215

      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:

      Linked frames, before and after

      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)

    • #55216
      rydesign
      Member

      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.

    • #55217

      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:

      Left to right, top to bottom threading

    • #55218
      rydesign
      Member

      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.

    • #55220

      … 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.

    • #55221
      rydesign
      Member

      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.

    • #55223

      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];
      }
      }
      }

    • #55233
      rydesign
      Member

      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

    • #55240

      .. 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 …).

    • #55344
      Harbs
      Member

      It looks like you're looking for TextStitch…

      https://www.rorohiko.com/wordpr&#8230;..extstitch/

    • #55355
      rydesign
      Member

      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.

Viewing 15 reply threads
  • You must be logged in to reply to this topic.
>