Skip to main content
Participant
April 6, 2010
Answered

Convert Graphic Frame to Text Frame

  • April 6, 2010
  • 3 replies
  • 1985 views

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

This topic has been closed for replies.
Correct answer Harbs.

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

3 replies

Harbs.
Harbs.Correct answer
Legend
April 6, 2010

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

HPS_RichAuthor
Participant
April 6, 2010

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

Harbs.
Legend
April 6, 2010

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

Jongware
Community Expert
Community Expert
April 6, 2010

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");
}
Inspiring
April 6, 2010

Hi Richard,

Try this

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

Regards,

Shonky