AI选择重叠的相同文本
//Select Replicated (Overlaping) Text Items v.1 -- CS,CS2//>=--------------------------------------
// This script removes all duplicate overlaping text items from a document.
// The ONLY parameters it checks are top and left coordinates, and text contents.
// Anchor points within one point of each other are considered the same.
// (tolerance can be adjusted by changing the 'tolerance' value.)
//
// The lower duplicate objects are selected for manual removal.
//
//>=--------------------------------------
// JS code (c) copyright: John Wundes ( john@wundes.com ) www.wundes.com
//copyright full text here: http://www.wundes.com/js4ai/copyright.txt
//////////////////////////////////////////////////////////////////
var selName = "仅本文档中)";
if(selection.length >0){
selName = "current selection";
var sel= activeDocument.selection;
var selectedTextFrames = new Array(0);
for (var all in sel){
if(sel.typename == "TextFrame"){
selectedTextFrames.push(sel);
}
}
sel = selectedTextFrames;
} else{
var sel= activeDocument.textFrames;
}
var dupeTextFrames= new Array(0);
var tolerance = 1;
var slen = sel.length;
for(var all=0; all <slen;all++){
checkDupe(sel,all);
}
//
alert(dupeTextFrames.length + " 个重叠的相同文本对象被找到("+selName+"");
if(dupeTextFrames.length>0){
activeDocument.selection = [];
for (all in dupeTextFrames){
dupeTextFrames.selected = true;
}
}
//---------------------------------------
function checkDupe(ob,n){
//t == objects so far
for(var t=0; t <n ;t++){
if(ob.typename == "TextFrame"){
if (isWithin(ob.left,ob.left,tolerance) &&
isWithin(ob.top,ob.top,tolerance) &&
ob.contents == ob.contents){
dupeTextFrames.push(ob);
break;
}
}
}
}
function isWithin(YposA,YposB,tol){
if(YposA==YposB){return true};
if(findDiff(YposA,YposB)<tol){
return true;
}
return false;
}
function findDiff(a,b){
if( a>0 && b>0 && b>a ||
a<0 && b>0 ||
a<0 && b<0 && a>b ){
return Math.abs(b-a);
}
return Math.abs(a-b);
}
--------------------------------------------
复制以上代码另存JS格式文件在AI中脚本调用即可。功能如名所示。
可不可以改成AI选择重叠的相同图形(矢量图)经常有些客人做的文件重叠了几层
页:
[1]