Skip to main content
Inspiring
July 28, 2022
Answered

What if the rectangle frame is empty?

  • July 28, 2022
  • 2 replies
  • 432 views

Hi all,

When there's an image in a graphic frame (a linked file), you can find out the file name, path, etc. But how do you check if that frame is empty?

The following script brings up the Link found message when there's a linked file in the frame, but doesn't bring up the Not found message if there isn't. It brings up an "object is invalid" error.

 

Any ideas?

if (app.selection[0].graphics[0].itemLink.filePath != null) {
  alert("Link found");
  }
  else {
    alert("Not found");
  }

 

This topic has been closed for replies.
Correct answer brian_p_dts
if (!app.selection[0].graphics.length) { //no graphic in frame }

2 replies

Community Expert
July 29, 2022

Hi @JustyR ,

depending on what you have selected you like to see deeper into your selected objects to get all the graphics there. Imagine you selected a group that contains some graphics.

 

For this purpose you could explore the contents or the length of the allGraphics array.

If it is 0 , you know that there is no graphic at all in your selected object.

 

Note, that if you select text and the text contains anchored images or a table with graphic cells that contain graphics the allGraphics array will also get them.:

 

alert( app.selection[0].allGraphics.length );

 

 

Another example: When a selected text frame contains overset text with anchored graphics, allGraphics will also collect them. Even if the graphics are in the overset text.

 

Regards,
Uwe Laubender
( Adobe Community Professional )

brian_p_dts
Community Expert
brian_p_dtsCommunity ExpertCorrect answer
Community Expert
July 28, 2022
if (!app.selection[0].graphics.length) { //no graphic in frame }
JustyRAuthor
Inspiring
July 28, 2022

Well, so deceptively simple. Thank you, Brian.

brian_p_dts
Community Expert
Community Expert
July 28, 2022

You're welcome. The important distinction is that the Link object is a child of the Graphic object.