Skip to main content
Known Participant
April 28, 2009
Question

Need help solving this tricky connect paths problem!

  • April 28, 2009
  • 2 replies
  • 1217 views

I need to convert a bunch of separate paths  in particular way so they create one single continuos path as shown in the attached PNG file.

It has me stumped. Does anyone know of a way to do this via scripting?

This topic has been closed for replies.

2 replies

MarkWalsh
Inspiring
April 30, 2009

Not a script, but the 'Concatenate' plug-in would be useful for doing this manually.

MarkWalsh
Inspiring
April 28, 2009

How often do you need to do this? I think that a script which would work properly may be more work than is worth the time.

I'm sure something like this could be done, but the real problem would be what would the next group of lines that you run the script on look like? Would a script that works for this circumstance work properly for another shape?

Here's some parameters to think about:

How do you determine which line segments (or endpoints) in the document need to be connected? All points in the document, or will you be working with a selection?

Once you determine the points (eliminating all that are already connected), how do you want them connected, and which point do you start with? Connect to the closest available point would seem what you want, but depending on how you determine which point to start with could give you different results.

You might want to loop through all eligible points, and save the distance to every other point into an array. Then, loop through connecting the 2 closest available points until you've connected every point.

Known Participant
April 30, 2009

I need to do this thousands of times. The example that I posted is just a simplified version of the graphic that I need to create. There will be many of these on each layout with dramatically different shapes. Each group of lines is contained inside of a closed vector


If I was instructing someone to do this manually I would tell them to connects all of the open paths contained within each closed vector so they make one continuous vector without crossing over itself.

I am looking into using a TSP (traveling sales person) application to see if I could possibly utilize it to connect the vectors.

Creating TSP artwork:

http://www.oberlin.edu/math/faculty/bosch/tspart-page.html

Thanks for your suggestions.

Larry G. Schneider
Community Expert
Community Expert
April 30, 2009

You might try this and see if it will work for you

http://www.illustrationetc.com/AI_Javascripts/PathScripts.htm