Copy link to clipboard
Copied
You see a group that consists of: on the left is a regular rectangle, on the right is a clipping mask, in which the mask is the same rectangle as on the left, and inside the mask are three rectangles (squares): white, above it orange, and above the orange white with a blue border. Simple, right?
The question is equally simple, how many groups are there from a scripting perspective? It would seem that the general group and the clipping group are just two groups. But Illustrator finds three groups.
Let's simplify and ungroup the outer group. Now we have two separate objects: a rectangle on the left and a clipping mask (group) on the right. So there's one group, and Illustrator will agree with us on that.
Question: where does the third group come from in the first case?
Copy link to clipboard
Copied
Hi @fastwind, I cannot reproduce this. At your first step I get 3 groupItems, same as you. But after ungrouping the outer group I get 2 groupItems (the clipping group and the clipped group). How are you measuring the groupItems' count? I'm using doc.groupItems.length.
Edit: to answer your question: where does the third group come from in the first case? You made two groups (the outer group and the group inside the clipping group) and the extra group is the clipping group—that's just how clipping masks work in Illustrator.
- Mark
Copy link to clipboard
Copied
Hi @m1b I used a recursive function that counted the groups differently than the method you cited - obviously this is the reason for the difference in counts. But maybe you meant: "the extra group is the clipped group".
Copy link to clipboard
Copied
Oh I see. I thought there was a group inside the clipping group. In that case the reason for your 3 count was an incorrect function. My count is 2—the outer group and the clipping group. When I ungroup the outer group, the count is 1.
Copy link to clipboard
Copied
there is no groups inside the clipping group in the above example - that's a correct note