7 Replies Latest reply on Apr 3, 2014 8:01 AM by DBLjan

    [AS] Help: Change text in <text frame> overflowing?

    DBLjan Level 2

      Hello again,

       

      i'm trying to fill text frames in my document with a randomtext from an array. Works fine by now.

      But not knowing how many characters fit in the text box, which has space for a single line about 10 words, i'll try to repeat the random process until theres no overflow in the box.

       

       

      The problem is this: When I change a text of the text frame, and it overflows, ill change the text again – but only the visible text gets overwritten, leaving the overflowing rest in the box and keeps adding up and never finishes the repeat-loop.

       

      if class of myPageItem as string = "text frame" then

                           

                            set text of myPageItem to "" & my TextFill()

                                 

                                                          repeat until overflows of myPageItem = false

                                                                            set text of myPageItem to "" & my TextFill()

                                                                  end repeat

                                                        end if


      Its the thingy with text of text frame…how do I overwrite every visible and non visible text in the box, any suggestions?

        • 1. Re: [AS] Help: Change text in <text frame> overflowing?
          RobertKyle Level 2

          I think you'll have better luck if you adress the story of the page item when adding text. Then address the page item itself to see if it's full.

           

          But is there something special about the fill text? I ask because the JS scripting dictionary includes this:

           

          TextFrameContents.PLACEHOLDER_TEXT  (Read Only)

          Data Type: number , Value: 1346925688

          Adobe InDesign CS5.5 (7.5) Object Model

          Fills the text frame with placeholder text.

           

          Which leads me to believe that you could invoke Adobe's built-in random text generator without a lot of guessing and checking. Not sure how to phrase that in the form of an AppleScript command.

          • 2. Re: [AS] Help: Change text in <text frame> overflowing?
            DBLjan Level 2

            set story of item k of myGroupPageItem to "changed text"

             

            doesnt work. I have to say Im not as expertized in scripting InD and Im trying to try-n-error the kinks out, but I'm getting better. I looked through the function-list of a text frame but couldnt find anything about the text in there.


            Also since firefox cant login to Adobe anymore since our IT tinkered with the proxy I have to use Safari and this wiered formating here comes along. Hope I can upload some images now to explain what im doing.

             

            Your suggestion about the randomtextfill is great, but I need some specific slogans in there.

             

            property Slogans : {"I dont fit in there ololo", "I wont either lolololol", "I do"}

             

            on TextFill(item)

                      set MyText to my R(Slogans)

                      return MyText

            end TextFill

             

             

             

            tell application "Adobe InDesign CS5.5"

             

                      if (count documents) > 0 then

                                set thisdoc to active document

             

                                repeat with i from 1 to count of pages of thisdoc

                                          set myPage to page i of thisdoc

             

                                          tell myPage

                                                    repeat with myCounter from 1 to (count page items)

                                                              set myPageItem to page item myCounter

             

                                                              if class of myPageItem as string = "group" then

                                                                        set myGroupPageItem to all page items of myPageItem as list

                                                                        repeat with k from 1 to length of myGroupPageItem

                                                                                  if (class of item k of myGroupPageItem as string) is "text frame" then

                                                                                            if text of item k of myGroupPageItem as string = "#text" then

                 set text of item k of myGroupPageItem to "" & my TextFill(myGroupPageItem)

                                                                                                      repeat until overflows of item k of myGroupPageItem = false

                                                                                                                set text of item k of myGroupPageItem to "" & my TextFill(myGroupPageItem)

                                                                                                      end repeat

                                                                                            end if

                                                                                  end if

                                                                        end repeat

                                                              end if


             

             

             


            • 3. Re: [AS] Help: Change text in <text frame> overflowing?
              DBLjan Level 2

              Here is my text frame…

               

              Bildschirmfoto 2014-04-03 um 10.07.28.png

               

              It randomizes my array and changes the text…but every characters overflowing (not visible) are untouched…

               

              Bildschirmfoto 2014-04-03 um 10.11.47.png

               

              So the text keeps adding up, and my loop wont finish…

               

              Bildschirmfoto 2014-04-03 um 10.11.55.png

              • 4. Re: [AS] Help: Change text in <text frame> overflowing?
                RobertKyle Level 2

                have you tried:

                 

                set contents of story of item k of myGroupPageItem to "changed text"

                 

                ?

                 

                Sorry, I don't have access to a Mac to test this.

                • 5. Re: [AS] Help: Change text in <text frame> overflowing?
                  DBLjan Level 2

                  I tested, and it doesnt work, sorry, appriciate it.

                   

                  Someone has to know this, if its mac or windows doesnt seem to mind, the procedure to access all text contained by the text frame must be obvious somehow…

                  • 6. Re: [AS] Help: Change text in <text frame> overflowing?
                    RobertKyle Level 2

                    It does work. What we have here is a failure to communicate. Here are the key points in javascript:

                     

                    myTextFrame = app.selection[0]; // I've selected a text frame with drag tool

                    myTextFrame.contents; //  the words that fit into the frame

                    myTextFrame.parentStory.contents; // the entire contents of the story, including any overset

                    myTextFrame.overflows; // true

                     

                    make sure that myTextFrame is a reference to a text frame object.

                    • 7. Re: [AS] Help: Change text in <text frame> overflowing?
                      DBLjan Level 2

                      Finally! Thank you so much, it works. Shame on me: I tried you solution in the loop, that was meant for grouped text object, but the "test"-text was ungrouped – so the preciouse code update coulnd grip.

                       

                      here is what worked for me:

                      set the contents of parent story of myPageItem to "" & my TextFill(myPageItem) & "!"

                       

                      Thanks alot, i owe you.