• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Does it Exist a way to remove particular shape made by aggregation paths by using script?

Community Beginner ,
Mar 31, 2021 Mar 31, 2021

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

noway.png

 

nofound.png

 

thak you for any help :c:

 

TOPICS
Scripting

Views

222

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 01, 2021 Apr 01, 2021

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
...

Votes

Translate

Translate
Adobe
Community Expert ,
Mar 31, 2021 Mar 31, 2021

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 01, 2021 Apr 01, 2021

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);    
                }
            }
        }
    }

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 01, 2021 Apr 01, 2021

Copy link to clipboard

Copied

LATEST

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);
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 31, 2021 Mar 31, 2021

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines