5 Replies Latest reply on Apr 6, 2010 7:03 AM by Harbs.

    Convert Graphic Frame to Text Frame

    HPS Rich

      Hi,

       

      I've a document with some basic frames in them. I need to convert them into text frames.

       

      I've tried PageItem.contentType = ContentType.TEXT_TYPE and while it changes the content type the page item still does not have insertionPoints.

       

      If I close the document directly after changing the content type then re open, the insertionPoints are accessable.

       

      What else do i need to do when converting the frame type?

       

      many thanks

       

      Richard

        • 1. Re: Convert Graphic Frame to Text Frame
          Shonkyin Level 3

          Hi Richard,

           

          Try this

           

          app.activeDocument.allPageItems[0].contentType = ContentType.TEXT_TYPE
          app.select(app.activeDocument.allPageItems[0].insertionPoints[0])
          

           

           

          Regards,

          Shonky

          1 person found this helpful
          • 2. Re: Convert Graphic Frame to Text Frame
            [Jongware] Most Valuable Participant

            You are correct -- there seems to be a minor lag between assigning the Content type and ID actually recognizing it as such.

             

            I tried a few random things that did not work -- forcing "recompose" and such -- until (finally!) trying this: an explicit Select of the new object does force ID to re-evaluate the type.

             

            r = app.activeDocument.rectangles.add();
            try {
             x = app.selection[0].insertionPoints.length;
             alert ("Found "+x+" insertion points");
            } catch (_)
            {
             alert ("No insertion points here");
            }
            r.contentType = ContentType.TEXT_TYPE;
            r.select();
            try {
             x = app.selection[0].insertionPoints.length;
             alert ("Found "+x+" insertion points");
            } catch (_)
            {
             alert ("No insertion points here");
            }
            1 person found this helpful
            • 3. Re: Convert Graphic Frame to Text Frame
              Harbs. Level 6

              The problem is caused by the peculiarities of InDesign's loose typing.

               

              You need to reevaluate the type like so:

               

              myPageItem.contentType = ContentType.TEXT_TYPE;
              myPageItem = myPageItem.getElements()[0];
              
              • 4. Re: Convert Graphic Frame to Text Frame
                HPS Rich Level 1

                thank you all for being so helpful,

                 

                yep in the end I set the pageitem variable to the pageitem in the document again and it fixed the problem, presume this is a Javascript bug and not Indesign itself?  I guess Indesign is doing some other process behind the scenes when you change the content type and Javascript doesn't realise the object has changed. lol

                 

                thanks again.

                 

                Richard

                • 5. Re: Convert Graphic Frame to Text Frame
                  Harbs. Level 6

                  I don't think it's really a bug.

                   

                  InDesign keeps interactions between the scripting layer and the C++ layer to a minimum to ensure maximum performance.

                   

                  You really don't want InDesign to reevaluate the object's type  each time you change a property...

                   

                  You are changing the object's class "behind the scripting engine's back", so the scripting layer is not aware of new properties.

                   

                  Harbs