Skip to main content
Inspiring
May 13, 2021
Answered

Illustrator Script checking object visibility

  • May 13, 2021
  • 1 reply
  • 1032 views

I'm working on building a document where it's content and images are imported from a CSV file. I'm then using a second script that I am writing to format that content and export a PDF. As part of my formatting script, I need to check to see if an imported image is set to visible or not.

Here is how I'm targeting/accessing my imported images in the script:

var doc = app.activeDocument;
var _pageItems = doc.pageItems;
var ImgItems = [];
var j = 0;
for (var i = 0; i < _pageItems.length; i++) {
    if (_pageItems[i].typename == "PlacedItem") {
        ImgItems[j] = _pageItems[i];
        j++;
    }
}

img1 = ImgItems[0];
img2 = ImgItems[1];
img3 = ImgItems[2];
img4 = ImgItems[3];

 

What I need to do, is check to see if img3 is visible or not. I've found some documentation on checking  the layers visibility, but I can't seem to get that to work for me.

All help is appreciated. Thank you.

This topic has been closed for replies.
Correct answer Silly-V

You can use PageItem.hidden property as the !condition to see if it is visible or not.

This is divergent from the way a Layer object does it which is a "visible" property and works inversely as a true condition.

1 reply

Silly-V
Silly-VCorrect answer
Legend
May 13, 2021

You can use PageItem.hidden property as the !condition to see if it is visible or not.

This is divergent from the way a Layer object does it which is a "visible" property and works inversely as a true condition.

GBoydAuthor
Inspiring
May 13, 2021

Oh perfect! That worked beautifully.

Thank you!