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

What if the rectangle frame is empty?

Contributor ,
Jul 28, 2022 Jul 28, 2022

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
412
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 , Jul 28, 2022 Jul 28, 2022
if (!app.selection[0].graphics.length) { //no graphic in frame }
Translate
Community Expert ,
Jul 28, 2022 Jul 28, 2022
if (!app.selection[0].graphics.length) { //no graphic in frame }
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
Contributor ,
Jul 28, 2022 Jul 28, 2022

Well, so deceptively simple. Thank you, Brian.

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

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

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 ,
Jul 29, 2022 Jul 29, 2022
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 )

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