I have written a perl program to optimize sandify pattern files. All my tests so far have had good results.
The program cuts out all back and forth motion along the edges of the table, eliminates all circling around the edges of the table, and forces shortest path around the table through 2 and 3 corners (3 corner paths are replaced by a single corner path). The result is usually greatly reduced pattern file size, faster drawing on the table because movement along the edge uses longest segment length (think acceleration/deceleration), excess motion is gone, and itās a lot less boring to watch because the unproductive edge motion is greatly reduced. It will save wear and tear on the table mechanism as well. All this leaves the pattern on the table unchanged except the edges sometimes looks a little ragged because thereās little motion along the edges to clean it up.
Itās extremely easy to use. Start it up by typing āperl sandify_trim_all.plā and then enter the pattern file name. Output is in a file called āclean.gcodeā.
I wrote it using Strawberry Perl in windoze, but I think it should work in any recent perl 5 install.
This is the first thing I have ever written in perl. It took me less than a week to write it (after thinking about it for months and abandoning every idea I had in that time). All you need to do is install perl and run the program- that should be easy.
I used strawberry perl in windows, if that helps, and it was very easy to set up. I think the code will be usable in any recent Perl 5 install.
I ran into a couple patterns that contained some residual useless motion after running trimify. I found that a second run of trimify on the ācleanā output file eliminated the residue. I then edited the program to make two full passes on the input pattern and it seems to work. I have yet to find any patterns that still contain any residue after running the new version of the program. The new program is called trimify2x.pl which you can grab here.
The new version now names the output file based on the input file name. if you enter āstarz.gcodeā the output file name will be āstarz_clean.gcodeā.
Unless someone finds a bug, Iām not planning any more changes.
Thanks for doing this. Iām currently working on v1pi, trying to cut another image. But I hope to integrate this into sandify, and having the algorithm written out and tested in detail really helps.
Great! The two pass version probably only needs to rerun the edge trimming to eliminate the residue that comes from the first pass. I donāt think itās necessary to run the corner trimming / substitution a second time.
Have you tried running trimmed files on your table?
This particular pattern, as produced by Sandify, requires about 2 hours to complete. With identical speed and acceleration settings, the ācleanā version from trimify2x finishes in about 57 minutes.
That came from your creation- Sandify. Iāve played with all the settings, quite a lotā¦
One of the things that trimify2x enables is patterns made with very high cycle counts. It trims out all the crap that would otherwise make those patterns too long and boring to watch.
I noticed that and fixed it in the current version.
I really understand a lot more why you want to limit the extra moves and see the unclipped pattern. Itās like youāre zoomed into a tiny facet of an incredibly complex pattern. Very neat.
The first part of the trimify2x.pl strips out excessive motion along each side of the table. That leaves sequences of corner statements that the second part of the program tries to reduce to minimum. I have detected a flaw in the algorithm that minimizes corner to corner sequences. If the corners are designated A, B, C, and D, you can have sequences like ABA or AA or ABAAD, etc., in which there are duplicates and reversals that the current algorithm doesnāt recognize and treat appropriately. Iām reviewing it now to see what needs to be done to fix it.
Iāve only seen problem behavior in one or two pattern files- the program works for 99% of pattern files.