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

PS Script to Calculate The Number of Times One Path Intersects with Another

Community Beginner ,
Apr 14, 2023 Apr 14, 2023

I wanted to see if anyone has work with a script to check how many times one path intersects with another.  I have a script that places a couple of straight paths and I want to branch based on the number of intersections.

 

For instance this would return "2"

Two.JPG

 

and this 4

4.JPG

There are cases depending on the count that I will either want to remove path or move the path, but I having figured out how to evaluate the intersections via script.

 

Thanks!

 

Jason

TOPICS
Actions and scripting
535
Translate
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
Adobe
People's Champ ,
Apr 14, 2023 Apr 14, 2023

I can offer you this option.

Create an empty layer. Set the foreground color to 128.

Stroke the first path with a 1px pencil set to Screen mode.

Do the same stroke with the second path.

Leave only this layer visible.

In the histogram, the number of pixels with a brightness of 192 will be the answer.

 

PS. I don't have a ready script. But maybe someone will do it. )

 

Translate
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 21, 2023 Apr 21, 2023
LATEST

Thanks for the idea.  I ended up doing something real similar by stroking both paths in their own layer, creating and intesection selection, then pasting the intersecting pixels in a third layer and counting the pixels with the histogram.

 

Translate
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