선택한 여러 개의 개체를 복사, 이동하는 일러스트레이터 스크립트.
그룹, 그룹 풀기(언그룹)에 대한 내용도 포함되어 있습니다.
//copy.jsx
//https://illustscript.tistory.com
var title = "copy";
var mm = 2.83464566929134;
var myBlue = new CMYKColor();
myBlue.black = 0;
myBlue.cyan = 100;
myBlue.magenta = 0;
myBlue.yellow = 0;
var myRed = new CMYKColor();
myRed.black = 0;
myRed.cyan = 0;
myRed.magenta = 100;
myRed.yellow = 0;
var docRef = activeDocument;
var sel = docRef.selection;
if(sel.length < 1){
alert("복사할 개체를 선택하세요");
}
else{
newGroup = docRef.groupItems.add();
copyItems(sel, newGroup);
coloring(sel);
}
function copyItems(item, grp){
for(var i=0; i<item.length; i++){
item[i].duplicate(grp, ElementPlacement.PLACEATEND); //copy
item[i].selected = false;
}
grp.translate(grp.width+20*mm, 0); //move
grp.selected = true;
Ungroup(docRef, grp); //grp의 요소를 docRef로 언그룹
sel = docRef.selection;
}
function Ungroup(whereToUngroup, group){ // where to ungroup? layer, document, other group?
for(var i=group.pageItems.length-1; i>=0; i--)
group.pageItems[i].move(whereToUngroup, ElementPlacement.PLACEATBEGINNING);
}
function coloring(item){
for(var i=0; i<item.length; i++){
item[i].fillColor = myBlue;
item[i].stroked = true;
item[i].strokeWidth = 2*mm;
item[i].strokeColor = myRed;
}
}
결과 :
'일러스트 스크립트' 카테고리의 다른 글
개체를 뒤집는 일러스트레이터 스크립트 (0) | 2024.08.27 |
---|---|
직선 및 곡선을 그리는 일러스트레이터 스크립트 (0) | 2024.07.31 |
선택 개체를 이동시키는 일러스트레이터 스크립트 (0) | 2024.07.26 |
선택 개체를 회전시키는 일러스트레이터 스크립트 (0) | 2024.07.26 |
일러스트레이터 스크립트로 텍스트(글씨) 입력하기 (0) | 2024.07.25 |