Sort curves to minimize travel distance

Thanks, from what I can tell, your tool paths look good. This is a comparison of tool path lengths:

minimize-travel_compare_2021Oct16a

P.S. Come to think of it, I didn’t need Weave either, or even to collect the infill curves in the sequence I used them in the loop.


minimize-travel_2021Oct16c.gh (84.8 KB)

1 Like

Having gone to some trouble to start my tool paths at alternate ends of the ‘Center curves’ (in theory, to minimize travel distance between layers/branches), I began to wonder how that strategy compares to your method? So I hacked an absurdly lazy “outer loop” to drive my version ‘16c’ and generate all four tool paths at once so I can connect them together. (it’s embarrassing but it’s done)

To my surprise, your code has slightly less overhead (travel distance between layers) than mine (271.4 vs.273.9). Thinking about it, my algorithm doesn’t necessarily end the tool path anywhere near the next branch’s start point!!

Yours:


minimize-travel-rg-1a_2021Oct16a.gh (76.3 KB)

Mine:


minimize-travel_2021Oct16d.gh (86.4 KB)

Congratulations, I think your algorithm is the best. I’d prefer to see it implemented with standard components instead of C# but the reasoning behind it is clever and appears to be sound.

1 Like

I can’t tell you how much I appreciate all of the help with this problem – I look forward to posting a before/after on the quality of the print that shows how much better the output is.

Strictly in case anyone is interested in playing with it (like @Joseph_Oster said, this has been a compelling problem for me as well), here’s one more version that adds the raw, unconnected infill lines as an input. I believe it’s the same as Joseph’s “culled short links” but just in case.

Many thanks again … this has been hugely educational and helpful!

minimize-travel_2021Oct16e-withraw.gh (124.1 KB)

It was necessary to add PShift (Shift Paths) after the “raw” infill lines to get four branches.

@RadovanG still wins. His:

Mine:

1 Like

And here’s the payoff:

Bad infill, causing lots of mayhem at the bottom of the piece as the nozzle drags back and forth across the border, leading to over-extrusion and smearing:

Good infill, with greatly reduced artifacts:

The remaining thin line is the transition from the flat layers for the base to a spiral for the upper portion of the piece; there’s no elegant way to do it (the nozzle can’t extrude cleanly at <50% or so of volume), but this is so much better and will be easy to sand.

2 Likes

I’m not sure if this comment went unnoticed in this thread but this one has helped me a great deal with sorting paths for my XY machine. I removed all the movements that weren’t on one Z-plane and got a nifty path sorting component from it. I think that in general this little script can do many simple operations on paths to connect the end and start points of closest paths, sorting curves, aligning curves.

I do wonder if there are different algorithms that can make the path sorting even faster, but I’m quite sure that ‘simply’ finding the next closest point is the fastest way. Maybe there could be some kind of sorter that does iterations, however it’s probably only a few seconds faster. This simple method is absolutely great. So thanks for sharing it. With a few small edits it was exactly what helped me out. I just wonder if there are use-cases in which this sorter actually makes production times longer.

Hello, I have also kind of the same issue. I am working on creating a continuous infill pattern that can be also optimized to minimize travel distance. The method of contouring, flipping half of the dispatched contour lines, and weaving them is working with simple surfaces. However, for the complex (flat) surfaces, I divide surfaces into subsurfaces to contour and weave them separately. Nevertheless, when the complexity of this flat surface increases, it is getting difficult to create a continuous and optimized infill pattern. What is an easy way to create this infill pattern as you do? I am sharing images and basic GH definitions to illustrate the situation that I am trying to explain. It would be great if you show me how to do it in an easy way, so I can also apply it to different complex flat surfaces. Like should I sort the curves based on specific logic and weave them or should I continue to stick with the idea of dividing subsurfaces with a certain logic?



complex_surface_zigzag_pattern.gh (24.9 KB)

Hi again, yesterday I was working on creating subsurfaces and weaving them separately with the Anemone loop. I believe this is still not the wisest way, however, maybe it is also the base idea of the optimized solution.


complex_surface_zigzag_pattern_01.gh (27.4 KB)

Hi everybody, I see the job of @Joseph_Oster and I find it very interesting.

I need to apply this to my curve, but it not respect the z coordinates.

I need to throw out of the code the curve sorted by travel and produce the gcode with Droid.

minimize-travel_nik_gyroid.gh (5.3 MB)