AI 页面适配对象脚本
可以配合 ai_scriptmix-master 插件使用方便复制已下内容到记事本打开就行另存jsx格式
var doc = app.activeDocument;
var obj = doc.selection;
var bnd = new Array();
if (documents.length > 0) {
if (obj.length > 0) {
bnd = getBounds(obj);
W = bnd - bnd;
H = bnd - bnd;
X = bnd;
Y = bnd;
} else {
doc.rulerOrigin = Array(0, 0);
bnd = 0;
bnd = doc.width;
bnd = doc.height;
bnd = 0;
}
doc.cropBox = bnd;
doc.cropStyle = CropOptions.Standard;
}
function getBounds(obj) {
var selObj1 = new Array();
var selObj2 = new Array();
var vgb1 = new Array();
var vgb2 = new Array();
var n = obj.length;
if (n > 0) {
if (obj.typename == "GroupItem" && obj.clipped && obj.pageItems.length > 1) {
clipObj = obj.pathItems.geometricBounds;
vgb1 = clipObj;
} else {
selObj1 = obj;
vgb1 = selObj1.visibleBounds;
}
if (n > 1) {
for (var i = 1; i < n; i += 1) {
selObj2 = obj;
if (obj.typename == "GroupItem" && obj.clipped && obj.pageItems.length > 1) {
vgb2 = obj.pathItems.geometricBounds;
} else {
vgb2 = selObj2.visibleBounds;
}
if (vgb1 > vgb2) {
vgb1 = vgb2
}
if (vgb1 < vgb2) {
vgb1 = vgb2
}
if (vgb1 < vgb2) {
vgb1 = vgb2
}
if (vgb1 > vgb2) {
vgb1 = vgb2
}
}
}
}
return vgb1;
}
页:
[1]