-
Notifications
You must be signed in to change notification settings - Fork 328
/
puzzleClipper.jsx
40 lines (32 loc) · 1.01 KB
/
puzzleClipper.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
Author: Alexander Ladygin (i@ladygin.pro)
Program version: Adobe Illustrator CS5+
Name: puzzleClipper.jsx;
Copyright (c) 2018
*/
#target illustrator
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
var items = selection,
i = items.length - 1,
target = selection[i],
isGroup = false;
if (i > 0) {
if (i === 1 && selection[0].typename === 'GroupItem') {
items = selection[0].pageItems;
i = items.length;
isGroup = selection[0];
}
while (i--) {
// create and move to group
var group = activeDocument.groupItems.add();
group.move((isGroup ? target : items[i]), ElementPlacement[(isGroup ? 'PLACEBEFORE' : 'PLACEAFTER')]);
// duplicate target object and move items
target.duplicate().moveToBeginning(group);
items[i].moveToBeginning(group);
// set properties
group.clipped = true;
if (!isGroup) items[i].clipping = true;
}
if (isGroup) isGroup.remove();
target.remove();
}