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

TextFrameItem nextFrame throws

Explorer ,
Dec 14, 2022 Dec 14, 2022

Hey guys,

I've been going through the documentation on using (docs)

 

TextFrameItem.nextFrame

 

From the docs as well:

- When you create a text frame, you also create a Story object.

- However, threading text frames combines the frames into a single story object.

- To thread frames, use the nextFrame or previousFrame property.

 

When I try to access this property on a TextFrame that I have I get the following error:

 

The requested property is not available for this type of text frame.

 

 

Has anyone else encoutered this error? My guess is that this means that there is no nextFrame to follow so I can just ignore it

TOPICS
Scripting
1.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

Community Expert , Dec 14, 2022 Dec 14, 2022

It is point text, so if you can add the check 

if(_textFrameItem.kind != TextType.POINTTEXT){
// check for nextFrame or previousFrame
}
Translate
Adobe
Community Expert ,
Dec 14, 2022 Dec 14, 2022

Hi, I am getting the nextFrame for every textFrame but previousFrame is null if textrame is not threaded. Try folloing if that helps you in your workflow.

var _textFrameItem = app.selection[0];
if (_textFrameItem.nextFrame != null) {
    var _nextFrame = _textFrameItem.nextFrame;
    alert(_nextFrame.contents)
}
if (_textFrameItem.previousFrame != null) {
    var _previousFrame = _textFrameItem.previousFrame;
    alert(_previousFrame.contents)
}
Best regards
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
Explorer ,
Dec 14, 2022 Dec 14, 2022

Hey @Charu Rajput,

 

Thank you for taking the time to assist with the manner.

 

Unfortunately, this check will throw an exception

_textFrameItem.nextFrame != null

 

My main goal with this is to understand why and on what condition it throws. I guess it's due to how the text is created within Illustrator.

 

For now, I am wrapping it in a try/catch block.

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 ,
Dec 14, 2022 Dec 14, 2022

Wrapping in try and catch is the correct solution. Could you please share your ai file to see how you created the textframe where you get this error?

Best regards
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
Explorer ,
Dec 14, 2022 Dec 14, 2022

I'm getting an error trying to upload it
The attachment's nextframe_throws2.ai content type (application/postscript) does not match its file extension and has been removed.

Will check later if I can upload it

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 ,
Dec 14, 2022 Dec 14, 2022

You can share drive or dropbox link, or may be by zipping the ai file.

Best regards
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
Explorer ,
Dec 14, 2022 Dec 14, 2022

Try this link, it seems to be uploaded for 30 days link

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 ,
Dec 14, 2022 Dec 14, 2022

It is point text, so if you can add the check 

if(_textFrameItem.kind != TextType.POINTTEXT){
// check for nextFrame or previousFrame
}
Best regards
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 ,
Dec 14, 2022 Dec 14, 2022

is your text Point text?

 

previousFrame, nextFrame only applies to Threaded Area Text frames.

 

var idoc = app.activeDocument;
var sel = idoc.selection; // select 2 Area Text Frames

var frame1 = sel[0];
var frame2 = sel[1];

// link frame2 to frame1
frame1.nextFrame = frame2;

alert(frame1.nextFrame.contents);
alert(frame2.previousFrame.contents);
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
Explorer ,
Dec 14, 2022 Dec 14, 2022
LATEST

@Charu Rajput and @CarlosCanto, thank you guys, you are awesome!

 

The issue is, as mentioned, that TextFrame cannot be Point Text. 

 

Again, big thanks!

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