What if the rectangle frame is empty?

Contributor ,
Jul 28, 2022 Jul 28, 2022

Copy link to clipboard

Copied

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");
  }

 

TOPICS
Scripting

Views

75

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
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Jul 28, 2022 Jul 28, 2022
if (!app.selection[0].graphics.length) { //no graphic in frame }

Likes

Translate

Translate
Adobe Community Professional ,
Jul 28, 2022 Jul 28, 2022

Copy link to clipboard

Copied

if (!app.selection[0].graphics.length) { //no graphic in frame }

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
community guidelines
Contributor ,
Jul 28, 2022 Jul 28, 2022

Copy link to clipboard

Copied

Well, so deceptively simple. Thank you, Brian.

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
community guidelines
Adobe Community Professional ,
Jul 28, 2022 Jul 28, 2022

Copy link to clipboard

Copied

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

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
community guidelines
Adobe Community Professional ,
Jul 29, 2022 Jul 29, 2022

Copy link to clipboard

Copied

LATEST

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 )

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
community guidelines