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
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:
- Write a
for
orwhile
loop that goes through the internal objects with the conditionif (obj.locked == false && obj.hidden == false
(shortenedif (obj.editable == true
) and sets attributeobj.selected = true
. - 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.