Access to Compound Shape

3 min readOct 4, 2022

A Compound Shape is an editable object consisting of two or more elements. It is created from the Pathfinder panel menu → Make Compound Shape or by applying a Boolean operation with the Alt key. A Compound Shape looks like a group, but has no similar properties and methods for controlling internal elements. For example, collections of PageItems or at least PathItems, like Compound Path.

But it turns out that in Illustrator’s DOM hierarchy, Compound Shape elements are placed in an invisible group-container that turns into a Compound Shape at the top level.

The elements inside can be of different types. One Compound Shape can be placed inside another

PluginItem shape typename, because it is created by the built-in PathfinderS.aip (Mac) or PathFinder Suite.aip (Windows). In the documentation, PluginItem properties and methods are limited to the simple: scale, remove, position, visibility, etc.

Selecting Compound Shape

In the simple case the selected property is enough to select the whole shape. If the elements inside are locked or hidden, you’ll encounter the problem described in the article “Hidden or locked objects in the group”.

Compound Shape, as a plugin group, is sensitive to the status of elements

In the API a shape has no collection of internal elements, so the only solution in this situation:

  • manually select one item,
  • get the topmost container group before the PluginItem,
  • recursively select all pageItems of this group.
var prnt = getTopParent(selection[0]);
function getTopParent(item) {
if (item.parent.typename !== 'PluginItem') {
return getTopParent(item.parent);
} else {
return item;
function selectGroup(group) {
for (var i = 0; i < group.pageItems.length; i++) {
var item = group.pageItems[i];
if (item.editable) {
if (item.typename == 'GroupItem') {
} else {
item.selected = true;

If a Compound Shape has another one nested in it, where elements may be hidden or locked, the loop will skip it. The solution is similar:

  • manually select at least one element in all shapes,
  • loop an invisible upper group-container to PluginItem for each item,
  • recursively select all pageItems of each group.

Changing Compound Shape

Continuing the theme with the selected element, we can change it inside the shape. Or we can get a list of all paths in the group and perform minimal operations with any of them: move, change points, delete, add a new element inside the group.

Compound Shape appearance

The user help says that by changing the appearance of any element of the shape, we change the global appearance. But trying to do the same via scripts leads to a bug.

The path contains information about the new color that has not been applied

Even if you use the script to change the color of each element and make an Expand, there will be no new color. The examples also don’t allow the script to add a stroke to a shape element. As an example, you also can’t add a stroke to a shape element with a script.




Sergey Osokin. Product Illustrator, Icon Designer, Script Developer (Ai, Ps). Writing about bugs and tricks in Adobe Illustrator scripts