如何在 Adob​​e Illustrator 中将画板添加到文档中?

how to add an artboard to a document in Adobe Illustrator?

我在 JavaScript 中为 Adob​​e Illustrator CC 2017 编写了一个脚本。在这个脚本中,我试图将画板添加到文档中,但它不起作用。

此处代码:

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

你的问题好像是新画板的尺寸问题。 查看脚本指南 here

add 方法将 artboardRect 作为参数。

下面的代码创建一个新文档并在第一个文档旁边添加一个画板。

/* 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();