Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Convert Graphic Frame to Text Frame

New Here ,
Apr 06, 2010 Apr 06, 2010

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

TOPICS
Scripting
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Apr 06, 2010 Apr 06, 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];

Translate
Engaged ,
Apr 06, 2010 Apr 06, 2010

Hi Richard,

Try this

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

Regards,

Shonky

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 06, 2010 Apr 06, 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");
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 06, 2010 Apr 06, 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];

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 06, 2010 Apr 06, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 06, 2010 Apr 06, 2010
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines