用Illustrator脚本将对象集中到多个艺术板

发布于 2025-01-22 14:25:50 字数 96 浏览 2 评论 0原文

假设,我在Illustrator中有5x5 25 Artboards,每个艺术板上都有不同的字母。我希望他们以每个艺术板为中心。有脚本吗? 我已经检查过,但通常他们都在一次工作。

Assume, I have 5x5 25 artboards in Illustrator with different letters on each. I want them to be centered on each artboard. Is there a script for it?
I have checked but generally they are all working for one artboard at once.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绅士风度i 2025-01-29 14:25:50

您可以在这里:

var doc = app.activeDocument;

for (var i=0; i<doc.artboards.length; i++) {
    app.selection = null;
    doc.artboards.setActiveArtboardIndex(i);
    doc.selectObjectsOnActiveArtboard();
    to_center(doc.artboards[i], app.selection[0]);
    app.selection = null;
}

function to_center(artboard, item){
    var artboard_x = artboard.artboardRect[0] + artboard.artboardRect[2];
    var artboard_y = artboard.artboardRect[1] + artboard.artboardRect[3];
    var x = (artboard_x - item.width)/2;
    var y = (artboard_y + item.height)/2;
    item.position = [x, y];
}

脚本在艺术板中间的每个艺术板上都放置了第一项。

在之前:

在此处输入图像描述“

之后:

”在此处输入图像说明”

Here you go:

var doc = app.activeDocument;

for (var i=0; i<doc.artboards.length; i++) {
    app.selection = null;
    doc.artboards.setActiveArtboardIndex(i);
    doc.selectObjectsOnActiveArtboard();
    to_center(doc.artboards[i], app.selection[0]);
    app.selection = null;
}

function to_center(artboard, item){
    var artboard_x = artboard.artboardRect[0] + artboard.artboardRect[2];
    var artboard_y = artboard.artboardRect[1] + artboard.artboardRect[3];
    var x = (artboard_x - item.width)/2;
    var y = (artboard_y + item.height)/2;
    item.position = [x, y];
}

The script puts a first item on every artboard in the middle of the artboard.

Before:

enter image description here

After:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文