Hidden or locked objects in the group

Ways to select a group with different object statuses:

  • Select the whole group — use the Selection Tool or click the circle next to the name in the Layers panel;
  • Select all visible unlocked objects — use Group Selection Tool or click in the empty area to the right of the circle
Two ways to select a group

Problem

In ExtendScript, changing the selected attribute of a group does not help.

app.activeDocument.pageItems[0].selected = true;

If there are free objects at the beginning of the group, they will be selected, but the script will stop with an error (Error 9063) at the first locked or hidden object.

Solution

How to choose a group within which we don’t know the statuses of objects:

  1. Write a for or while loop that goes through the internal objects with the condition if (obj.locked == false && obj.hidden == false (shortened if (obj.editable == true) and sets attribute obj.selected = true.
  2. Cycle through all objects, temporarily make them all visible and unlock them. Then select the group. But then you have to save all the statuses to a temporary array to return them at the end.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
AiScripts

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