4 Replies Latest reply on Oct 6, 2010 2:29 PM by [Jongware]

    Script Tweak Needed - CopyCutter

    GD_lewis

      Hi everyone,

       

      I was hoping some of you may be able to help me out quickly, by tweaking a script that had previously been posted here for me. The thread containing the script is: http://forums.adobe.com/message/2866867

       

      The premise is exactly the same, however the copy to be cut is now a bit different. The before and after graphic can be seen here: http://cl.ly/8f944af3ee0cc51ef1d0

       

      Your help would be greatly appreciated!

       

      Lewis

        • 1. Re: Script Tweak Needed - CopyCutter
          GD_lewis Level 1

          Anybody? Surely I've not got you all stumped!

           

          If you need me to clarify anything, let do me know.

           

          Cheers,

          Lewis

          • 2. Re: Script Tweak Needed - CopyCutter
            Harbs. Level 6

            Most of us are probably too busy with work to research old threads. (I know I am.)

             

            If you provide us with a script snippet that you need changed, we may be able to help...

             

            Harbs

            1 person found this helpful
            • 3. Re: Script Tweak Needed - CopyCutter
              GD_lewis Level 1

              Thanks Harbs. I understand.

               

              Here is the previous script:

              http://snipt.org/klmx/ (sorry I couldn't get it to retain line breaks here)

              • 4. Re: Script Tweak Needed - CopyCutter
                [Jongware] Most Valuable Participant

                Heh. One of those things that's a bit nastier than they appear, it seems!

                 

                Problem #1 was determining how much text to copy to the new frames. The previously used way of counting single lines didn't work anymore -- so I use a GREP expression to find "anything except (2 or more hard returns)" -- I think I got the expression right.

                Next problem (#2): what's with the "OVER" that needs to be removed?? I tried several approaches, but in the end I just went for killing them right off the bat at the start... All that's left ought to be 2-return (or more) separated paragraphs.

                 

                After that it was finally the proverbial breeze -- the complicated GREP marks the text to copy from first to last character; the top is determined from the line above it. I hope it does everything you hoped for.

                 

                //DESCRIPTION:CopyCutter 3 — Cut more Copy into Slivers
                // Jongware, 6-Oct-2010
                
                if (app.selection.length == 1 && app.selection[0] instanceof TextFrame)
                {
                     f = app.selection[0];
                     app.findGrepPreferences = null;
                     app.changeGrepPreferences = null;
                     app.findGrepPreferences.findWhat = "(?i)\\r\\r+OVER\\r\\r+";
                     app.changeGrepPreferences.changeTo = '\\r\\r'
                     f.changeGrep();
                     app.findGrepPreferences = null;
                     app.findGrepPreferences.findWhat = "(.|(?<!\\r)\\r(?!\\r))+";
                     list = f.findGrep();
                     for (i=0; i<list.length; i++)
                     {
                          newf = f.duplicate();
                          newf.texts[0].remove();
                          par = f.texts[0].characters.itemByRange (list[i].characters[0], list[i].characters[-1]);
                          par.duplicate (LocationOptions.AT_BEGINNING, newf.texts[0]);
                          if (i > 0)
                               top = f.characters.previousItem(list[i].characters[0]).baseline;
                          else
                               top = f.geometricBounds[0];
                          bot = list[i].characters[-1].baseline;
                          newf.geometricBounds = [ top, f.geometricBounds[1], bot, f.geometricBounds[3] ];
                     }
                
                     f.remove();
                
                     app.findGrepPreferences = null;
                     app.changeGrepPreferences = null;
                }