How to check the global status of an object

2 min readMay 31, 2022


From the locked and hidden boolean properties the object statuses are read and written. The property values may not show the actual status of the object in the Adobe Illustrator document. It depends on:

  • parent layer statuses,
  • parent group,
  • combinations of groups with depth, layers with sublayers.

Let’s try to find out the status and select an object inside the locked group:

if (!activeDocument.pageItems[1].locked) {
alert('Item not locked');
activeDocument.pageItems[1].selected = true;
For the user the Path is locked, for the script — no, but also not selected

The same result would be if you lock or hide the parent layer. We can move, delete an object using the script, but not select or tell the user the true status.


By recursion we can check the statuses of the parent containers for the object. Let’s write Boolean values to an array.

var item = activeDocument.pageItems[2];
var itemState = [];
itemState[0] = item.locked ? true : false;
itemState[1] = item.hidden ? true : false;
checkParentState(item, itemState);
alert('Item state\n' + 'locked: ' + itemState[0] + '\n' +
'hidden: ' + itemState[1]);
function checkParentState(item, arr) {
var prnt = item.parent;
try {
switch (prnt.typename) {
case 'GroupItem':
if (!prnt.editable) arr[0] = true;
checkParentState(prnt, arr);
case 'Layer':
if (prnt.locked) arr[0] = true;
if (!prnt.visible) arr[1] = true;
checkParentState(prnt, arr);
} catch (e) {}
Recursion will detect any combination of statuses




Sergey Osokin. I’m a illustrator & Script Developer (Ai, Ps). Writing about bugs and tricks.