Copy link to clipboard
Copied
hello,
i am just trying to do about subject
i checked document several times
but i have no idea how to do this.....
document layer is looks like below image
 
thak you for any help :c:
Awesome! If you look at the top item's geometricBounds properties, you can compare (and subtract to get the distance apart). Also can simply use left and top and width and height properties. Also visibleBounds. 🙂
P.S. to get the pathPoints of a CompoundPathItem, you must ask for its pathItems specifically:
var myPathItems = []
if (item.typename == 'CompoundPathItem') {
for (var i = 0; i < item.pathItems.length; i++) {
myPathItems.push(item.pathItems[i];
}
} else if ( item.pathPoi
...
Copy link to clipboard
Copied
Simplest case is when you can differentiate the items based on, for example, number of points.
var items = app.activeDocument.pageItems;
var exampleItem = items[0];
if (exampleItem.pathPoints != undefined){
if (exampleItem.pathPoints.length == 6) {
alert ('example item has six path points');
}
}
Would that be enough to go on? If you need more sophistication, you may need to analyse the relationships between points, which is a lot more involved.
Copy link to clipboard
Copied
i reffered to your answer while making script
it had work ! Thank you for your answer
but as you replyed, i could not select some complex path shapes ...
by the way, is there a way to calcurate distance between any object ;
When I tried to calculate the distance with one object as the base point by using for loop
it was too heavy and froze :o: [saveTrianglePos]
thank you for your kindness ;c;
var select = app.activeDocument.selection;
var saveTrianglePos = [];
for(var i = select.length -1;i > -1;i--){
if(select[i].typename == "PathItem"){
if(select[i].pathPoints.length == 3){
if(select[i].closed){
saveTrianglePos.push(select[i].pathPoints[0].anchor[0]);
select[i].remove();
};
}else if(select[i].pathPoints.length == 2){
//*PATH VECTOR LENGTH*
var v2 = Math.sqrt(
Math.pow(
Math.abs(
select[i].pathPoints[1].anchor[0] -
select[i].pathPoints[0].anchor[0]),2) +
Math.pow(
Math.abs(
select[i].pathPoints[1].anchor[1] -
select[i].pathPoints[0].anchor[1]),2));
//alert(v2);
if(v2 < 2.5){
if(select[i].strokeColor.red < 50 && select[i].strokeColor.green < 50 && select[i].strokeColor.blue < 50){
select[i].remove();
}
}else{
//select[i].strokeWidth = 1.5;
//select[i].resize(150,150);
}
}
}
}
Copy link to clipboard
Copied
Awesome! If you look at the top item's geometricBounds properties, you can compare (and subtract to get the distance apart). Also can simply use left and top and width and height properties. Also visibleBounds. 🙂
P.S. to get the pathPoints of a CompoundPathItem, you must ask for its pathItems specifically:
var myPathItems = []
if (item.typename == 'CompoundPathItem') {
for (var i = 0; i < item.pathItems.length; i++) {
myPathItems.push(item.pathItems[i];
}
} else if ( item.pathPoints != undefined {
myPathItems.push(item);
}
Copy link to clipboard
Copied
post an actual file, it might be possible to target items by a specific property, ie z-order, color, size, etc.