- 精华
- 活跃值
-
- 积分
- 22163
- 违规
-
- 印币
-
- 鲜花值
-
- 在线时间
- 小时
累计签到:1724 天 连续签到:1002 天
|
发表于 2019-12-17 08:05:21
|
显示全部楼层
本帖最后由 印刷人 于 2019-12-17 08:06 编辑
AI选择对象创建画板--支持蒙版,也是个脚本文件。。。。。。。。
var doc = app.activeDocument;
var theSelect = doc.selection;
var objGBCheck = false; //几何边界与可视边界 切换 //true //false
var addLayerCheck = false; //是否新建图层
var addColorCheck = false; //边框是否填色
var layName = "边框图层"; //新建的图层名称
if (theSelect.length > 0) {
for (i = 0; i < theSelect.length; i++) { //批处理多个选择物体
var bound = NO_CLIP_BOUNDS(theSelect);
var left = bound[0]; //左
var tops = bound[1]; //上
var width = bound[2] - bound[0]; //宽
var height = bound[1] - bound[3]; //高
if (addLayerCheck == true) {
try {
var newLayer = doc.layers[layName]; //查找图层
newLayer.locked = false;
newLayer.visible = true;
} catch(err) {
var newLayer = doc.layers.add();//新建图层
newLayer.name = layName;
}
var rect = newLayer.pathItems.rectangle(tops, left, width, height); //创建边框
} else {
var rect = doc.activeLayer.pathItems.rectangle(tops, left, width, height); //创建边框
}
var newColor = new CMYKColor(); //创建 CMYK 颜色
newColor.cyan = 0;
newColor.magenta = 0;
newColor.yellow = 0;
newColor.black = 100;
if (addColorCheck == true) {
rect.stroked = true; //描边
rect.strokeWidth = 0.25; //线粗
rect.strokeColor = newColor; //描边的颜色
} else {
rect.stroked = false; //无描边
}
rect.filled = false; //不填充
rect.fillColor = NoColor; //无填充色
rect.selected = true; //被选中
doc.artboards.add(bound);
}
} else {
alert("唉吆!\n必须先选择对象文件哦!!", "错误提示");
}
function NO_CLIP_BOUNDS(the_obj) {
var NO_CLIP_OBJECTS_AND_MASKS = new Array();
GET_NO_CLIP_OBJECTS_AND_MASKS(the_obj);
var v_left = new Array();
var g_left = new Array();
var v_top = new Array();
var g_top = new Array();
var v_right = new Array();
var g_right = new Array();
var v_bottom = new Array();
var g_bottom = new Array();
for (var i = 0; i < NO_CLIP_OBJECTS_AND_MASKS.length; i += 1) {
g_left = NO_CLIP_OBJECTS_AND_MASKS.geometricBounds[0];
v_left = NO_CLIP_OBJECTS_AND_MASKS.visibleBounds[0];
g_top = NO_CLIP_OBJECTS_AND_MASKS.geometricBounds[1];
v_top = NO_CLIP_OBJECTS_AND_MASKS.visibleBounds[1];
g_right = NO_CLIP_OBJECTS_AND_MASKS.geometricBounds[2];
v_right = NO_CLIP_OBJECTS_AND_MASKS.visibleBounds[2];
g_bottom = NO_CLIP_OBJECTS_AND_MASKS.geometricBounds[3];
v_bottom = NO_CLIP_OBJECTS_AND_MASKS.visibleBounds[3];
}
var GV_Bounds = objGBCheck ? "true": "false";
switch (GV_Bounds) {
case "true":
var g_L = MIN_IN_ARRAY(g_left);
var g_T = MAX_IN_ARRAY(g_top);
var g_R = MAX_IN_ARRAY(g_right);
var g_B = MIN_IN_ARRAY(g_bottom);
return [g_L, g_T, g_R, g_B];
break;
case "false":
var v_L = MIN_IN_ARRAY(v_left);
var v_T = MAX_IN_ARRAY(v_top);
var v_R = MAX_IN_ARRAY(v_right);
var v_B = MIN_IN_ARRAY(v_bottom);
return [v_L, v_T, v_R, v_B];
break;
}
function GET_NO_CLIP_OBJECTS_AND_MASKS(the_obj) {
if (IS_CLIP(the_obj)) {
NO_CLIP_OBJECTS_AND_MASKS.push(the_obj.pageItems[0]);
return;
}
if (the_obj.constructor.name == "GroupItem") {
try {
var N_sub_obj = the_obj.pageItems.length;
for (var i = 0; i < N_sub_obj; i += 1) {
GET_NO_CLIP_OBJECTS_AND_MASKS(the_obj.pageItems);
}
} catch(error) {
}
return;
}
NO_CLIP_OBJECTS_AND_MASKS.push(the_obj);
return;
}
}
function IS_CLIP(the_obj) {
try {
if (the_obj.constructor.name == "GroupItem") {
if (the_obj.clipped) {
return true;
}
}
} catch(error) {
}
return false;
}
function MAX_IN_ARRAY(the_array) {
var MAX = the_array[0];
for (var i = 0; i < the_array.length; i += 1) {
if (the_array > MAX) {
MAX = the_array
}
}
return MAX;
}
function MIN_IN_ARRAY(the_array) {
var MIN = the_array[0];
for (var i = 0; i < the_array.length; i += 1) {
if (the_array < MIN) {
MIN = the_array
}
}
return MIN;
}
|
|