illustrator脚本 一键修改画板尺寸。这是一个简易的修改画板尺寸到一个指定尺寸。
changeArtboards();
function changeArtboards() {
var PT_TO_MM = 2.834645668;
var doc = function() {
return activeDocument;
}();
/**
* @param {Object} opts.left, opts.top, opts.width, opts.height
* */
function ArtbOptions(opts) {
this.left = opts.left * PT_TO_MM;
this.top = -opts.top * PT_TO_MM;
this.width = (opts.width + opts.left) * PT_TO_MM;
this.height = (-opts.height - opts.top) * PT_TO_MM;
}
var opts = new ArtbOptions({
left: 10, top: 10, width: 100, height: 200
});
/* if (opts.width <= 0) {
throw new opts.ErrWidth();
}
if (opts.height <= 0) {
throw new opts.ErrHeight();
}*/
try {
doc.artboards.add([opts.left, opts.top, opts.width, opts.height]);
} catch (e) {
alert(e.description);
}
}