Tue, 19 Jan 2021 20:25:47 +0100
NeoCube laser cutting improvements
40 | 1 | import argparse |
2 | ||
3 | def gen_speedtest(args): | |
4 | fd = open(args.file, 'wb') | |
41 | 5 | axis = args.axis.upper() |
6 | if axis == 'X': | |
40 | 7 | pos = [0, args.dx] |
41 | 8 | fd.write("G0 Y%.2f F%i\n" % ( |
40 | 9 | args.dy / 2, args.min * 60)) |
10 | else: | |
11 | pos = [0, args.dy] | |
41 | 12 | fd.write("G0 X%.2f F%i\n" % ( |
40 | 13 | args.dx / 2, args.min * 60)) |
14 | ||
41 | 15 | loops = (args.max - args.min) / args.inc |
40 | 16 | speed = args.min |
17 | for loop in range(loops): | |
41 | 18 | fd.write("G0 %s%.2f F%i\n" % ( |
19 | axis, pos[0], speed * 60)) | |
20 | fd.write("G0 %s%.2f F%i\n" % ( | |
21 | axis, pos[1], speed * 60)) | |
40 | 22 | |
23 | speed += args.inc | |
24 | ||
25 | fd.close() | |
26 | ||
27 | ||
28 | def main(): | |
29 | parser = argparse.ArgumentParser() | |
30 | parser.add_argument("axis", help="Define X or Y axis") | |
31 | parser.add_argument("file", help="Output gcode filename") | |
32 | parser.add_argument("--min", type=int, default=100, help="Minimum speed mm/s (100)") | |
33 | parser.add_argument("--max", type=int, default=200, help="Maximum speed mm/s (200)") | |
34 | parser.add_argument("--dx", type=int, default=200, help="Maximum X dimension (200)") | |
35 | parser.add_argument("--dy", type=int, default=200, help="Maximum Y dimension (200)") | |
41 | 36 | parser.add_argument("--inc", type=int, default=20, help="Speed increment after each line") |
40 | 37 | |
38 | args = parser.parse_args() | |
39 | ||
40 | gen_speedtest(args) | |
41 | ||
42 | if __name__ == '__main__': | |
43 | main() |