Highlighted

textFrame.itemLayer throw an incorrect object for this request error

Explorer ,
Apr 08, 2020

Copy link to clipboard

Copied

Hi,

I'm facing a new problem in a JS script for InDesign.
I'm doing this :

 

if (startTF.itemLayer.visible) {
   //do work
}

 

Where startTF is a textFrame object. I've checked it with startTF instanceof TextFrame => true and startTF.constructor => TextFrame().
I have this error throwing "Incorrect object for this request".

According to documentations I've read, textFrame.itemLayer is an existing property.

How can I test this in order to manage this error ? (Waiting for a best way, I'm using 'try catch' ..)

PS : What I've tried so far unsuccessfully :

  • startTF.itemLayer
  • startTF.hasOwnProperty('itemLayer') => return true
  • 'itemLayer' in startTF => return true
     

Thanks

Adobe Community Professional
Correct answer by Peter Kahrel | Adobe Community Professional

If an embedded text frame's parent character has no parent text frame, then it is in overset text:

if (myFrame.parent.parentTextFrames.length === 0) {
  // myFrame is in overset text
}

Maybe first do a test whether myFrame is embedded:

if (myFrame.parent instanceof Character && myFrame.parent.parentTextFrames.length === 0) {

P. 

TOPICS
How to, Scripting, SDK

Views

534

Likes

Translate

Translate

Report

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

textFrame.itemLayer throw an incorrect object for this request error

Explorer ,
Apr 08, 2020

Copy link to clipboard

Copied

Hi,

I'm facing a new problem in a JS script for InDesign.
I'm doing this :

 

if (startTF.itemLayer.visible) {
   //do work
}

 

Where startTF is a textFrame object. I've checked it with startTF instanceof TextFrame => true and startTF.constructor => TextFrame().
I have this error throwing "Incorrect object for this request".

According to documentations I've read, textFrame.itemLayer is an existing property.

How can I test this in order to manage this error ? (Waiting for a best way, I'm using 'try catch' ..)

PS : What I've tried so far unsuccessfully :

  • startTF.itemLayer
  • startTF.hasOwnProperty('itemLayer') => return true
  • 'itemLayer' in startTF => return true
     

Thanks

Adobe Community Professional
Correct answer by Peter Kahrel | Adobe Community Professional

If an embedded text frame's parent character has no parent text frame, then it is in overset text:

if (myFrame.parent.parentTextFrames.length === 0) {
  // myFrame is in overset text
}

Maybe first do a test whether myFrame is embedded:

if (myFrame.parent instanceof Character && myFrame.parent.parentTextFrames.length === 0) {

P. 

TOPICS
How to, Scripting, SDK

Views

535

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 08, 2020 0
Adobe Community Professional ,
Apr 08, 2020

Copy link to clipboard

Copied

i guess this textframe is anchored and is part of overset text of the parent textframe. You can test this and if it is so then you could place this statement in a try catch block, if the code lands in the catch block that means its present in an overset text and you could deal it with accordingly as per your requirments.

 

-Manan

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 08, 2020 0
Explorer ,
Apr 08, 2020

Copy link to clipboard

Copied

Thanks for your reply.
How can I test that it's present in an overset text please ? I'm not sure of how to do this.

Regards

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 08, 2020 0
Adobe Community Professional ,
Apr 10, 2020

Copy link to clipboard

Copied

Hi Emilie,

 

There is no direct api to tell if a textframe is within overset text or not. By verifying i meant that you could visually scan the document to see which textframe corresponds to the object that is causing this error. If you see any textframe with overset in the document check if its overset text contains an embedded textframe and if it is then verify if this embedded frame is the same as the one you refer via code.

 

If the textframe is embedded in another frame its parent should correspond to a character. Once we do verify by all this semi partial automated process that the frame is indeed embedded in a overset text, then the try catch block with the itemLayer code would actually serve as the test for this condition.

 

-Manan

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 10, 2020 1
Adobe Community Professional ,
Apr 10, 2020

Copy link to clipboard

Copied

If an embedded text frame's parent character has no parent text frame, then it is in overset text:

if (myFrame.parent.parentTextFrames.length === 0) {
  // myFrame is in overset text
}

Maybe first do a test whether myFrame is embedded:

if (myFrame.parent instanceof Character && myFrame.parent.parentTextFrames.length === 0) {

P. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 10, 2020 3
Explorer ,
Apr 14, 2020

Copy link to clipboard

Copied

Thanks for both answers.

It helps me to understand how it works.
I work on an automatic process so I will use Peter's test to achieve this.

Thanks

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 14, 2020 1