2017-04-21 1 views
0

Adobe Illustrator CC 2017 용 JavaScript로 스크립트를 작성했습니다.이 스크립트에서는 함수에서 문서에 대지를 추가하려고했지만 작동하지 않습니다.Adobe Illustrator에서 문서에 대지를 추가하는 방법은 무엇입니까?

여기에 코드 :

function addArtboard() { 
 
    var doc = app.documents.add(null,1000,1000); 
 
    doc = app.activeDocument; 
 
    var artboards = doc.artboards; 
 
    artboards.add([0 , 0, 1000, 1000]); 
 
} 
 
    
 
addArtboard();

답변

0

귀하의 문제는 새로운 아트 보드의 측정 것으로 보인다. 스크립팅 가이드 here을 살펴보십시오.

add 메소드는 artboardRect을 인수로 취합니다.
screenshot from scripting guide

아래의 코드는 새 문서를 만들고 첫 번째 옆에 대지를 추가합니다.

/* global app, $ */ 
function addArtboard() { 
    var doc = app.documents.add(); // create a doc with defaults 
    var firstArtBoard = doc.artboards[0]; // get the default atboard 
    // inspect its properties 
    for(var prop in firstArtBoard) { 
    // exclude protptypes 
    if(firstArtBoard.hasOwnProperty(prop)) { 
     $.writeln(prop); 
    } 
    } 
    // there is a rect property 
    // take a look at the values 
    $.writeln(firstArtBoard.artboardRect); 
    // create a artboard with the same size and an 
    // offset of 5 points to the right 
    var x1 = firstArtBoard.artboardRect[2] + 10; 
    var y1 = firstArtBoard.artboardRect[1]; 
    var x2 = x1 + firstArtBoard.artboardRect[2]; 
    var y2 = firstArtBoard.artboardRect[3]; 
    doc.artboards.add([x1, y1, x2, y2]); 
} 

addArtboard(); 
관련 문제