action="store", type="string", dest="output_file") parser.add_option("-i", "--image", action="store_true", dest="image", default=False) options, args = parser.parse_args() # Check for required options for required in ("output_file", ): if getattr(options, required, None) is None: print "Missing required option '%s'" % required print USAGE.strip() % argv[0] exit(1) # Check positional arguments if len(args) <> 1: print USAGE.strip() % argv[0] exit(1) # Process the file gcode = loadGCode(args[0]) if (gcode.minx <> 0) or (gcode.miny <> 0): print "Translating file by dx = %0.4f, dy = %0.4f" % (-gcode.minx, -gcode.miny) gcode = gcode.clone(Translate(-gcode.minx, -gcode.miny)) else: print "No translation required." saveGCode(options.output_file, gcode) if options.image: gcode.render(splitext(options.output_file)[0] + ".png")
""" #--- Main program if __name__ == "__main__": # Set up program options parser = OptionParser() parser.add_option("-c", "--cut", action="store", type="float", dest="cut_depth") parser.add_option("-s", "--safe", action="store", type="float", dest="safe_depth") parser.add_option("-o", "--output", action="store", type="string", dest="output_file") options, args = parser.parse_args() # Check for required options for required in ("output_file", ): if getattr(options, required, None) is None: print "Missing required option '%s'" % required print USAGE.strip() % argv[0] exit(1) # Check positional arguments if len(args) <> 1: print USAGE.strip() % argv[0] exit(1) # Set up the source file and collect the depth information source = args[0] if (options.cut_depth is None) and (options.safe_depth is None): print "You haven't asked me to do anything!" exit(1) # Now process the file gcode = loadGCode(source) gcode = gcode.clone(ZLevel(cut = options.cut_depth, safe = options.safe_depth)) saveGCode(options.output_file, gcode)
parser.add_option("-s", "--safe", action="store", type="float", dest="safe_depth") parser.add_option("-o", "--output", action="store", type="string", dest="output_file") options, args = parser.parse_args() # Check for required options for required in ("output_file", ): if getattr(options, required, None) is None: print "Missing required option '%s'" % required print USAGE.strip() % argv[0] exit(1) # Check positional arguments if len(args) <> 1: print USAGE.strip() % argv[0] exit(1) # Set up the source file and collect the depth information source = args[0] if (options.cut_depth is None) and (options.safe_depth is None): print "You haven't asked me to do anything!" exit(1) # Now process the file gcode = loadGCode(source) gcode = gcode.clone(ZLevel(cut=options.cut_depth, safe=options.safe_depth)) saveGCode(options.output_file, gcode)
""" #--- Main program if __name__ == "__main__": # Set up program options parser = OptionParser() parser.add_option("-o", "--output", action="store", type="string", dest="output_file") parser.add_option("-i", "--image", action="store_true", dest="image", default=False) options, args = parser.parse_args() # Check for required options for required in ("output_file", ): if getattr(options, required, None) is None: print "Missing required option '%s'" % required print USAGE.strip() % argv[0] exit(1) # Check positional arguments if len(args) <> 1: print USAGE.strip() % argv[0] exit(1) # Process the file gcode = loadGCode(args[0]) if (gcode.minx <> 0) or (gcode.miny <> 0): print "Translating file by dx = %0.4f, dy = %0.4f" % (-gcode.minx, -gcode.miny) gcode = gcode.clone(Translate(-gcode.minx, -gcode.miny)) else: print "No translation required." saveGCode(options.output_file, gcode) if options.image: gcode.render(splitext(options.output_file)[0] + ".png")