Exemplo n.º 1
0
def main(argv):
	try:
		opts, args = getopt.getopt(argv, "h", [
			"help",
			"line-width=",
			"start-delay=",
			"stop-delay=",
			"xy-feedrate=",
			"z-feedrate=",
			"z-height="
		])
	except getopt.GetoptError:
		usage()
		sys.exit(2)
        
	z_height = 0
	"0.0"
	z_feedrate = 150
	"150"
	xy_feedrate = 2000
	"3500"
	start_delay = 60
	"60"
	stop_delay = 120
	"120"
	line_width = 0.5
	"0.50"

	for opt, arg in opts:
		if opt in ("-h", "--help"):
			usage()
			sys.exit()
		elif opt in ("--z-feedrate"):
			z_feedrate = float(arg)
		elif opt in ("--z-height"):
			z_height = float(arg)
		elif opt in ("-xy-feedrate"):
			xy_feedrate = float(arg)
		elif opt in ("--start-delay"):
			start_delay = float(arg)
		elif opt in ("--stop-delay"):
			stop_delay = float(arg)
		elif opt in ("--line-width"):
			line_width = float(arg)

	parser = DxfParser(open(argv[-1], 'r'))
	context = GCodeContext(z_feedrate, z_height, xy_feedrate, start_delay, stop_delay, line_width, argv[-1])
	parser.parse()
	for entity in parser.entities:
		entity.get_gcode(context)
	context.generate()
Exemplo n.º 2
0
def main(argv):
    try:
        opts, args = getopt.getopt(argv, "h", [
            "help", "line-width=", "start-delay=", "stop-delay=",
            "xy-feedrate=", "z-feedrate=", "z-height="
        ])
    except getopt.GetoptError:
        usage()
        sys.exit(2)

    z_height = 0
    "0.0"
    z_feedrate = 150
    "150"
    xy_feedrate = 2000
    "3500"
    start_delay = 60
    "60"
    stop_delay = 120
    "120"
    line_width = 0.5
    "0.50"

    for opt, arg in opts:
        if opt in ("-h", "--help"):
            usage()
            sys.exit()
        elif opt in ("--z-feedrate"):
            z_feedrate = float(arg)
        elif opt in ("--z-height"):
            z_height = float(arg)
        elif opt in ("-xy-feedrate"):
            xy_feedrate = float(arg)
        elif opt in ("--start-delay"):
            start_delay = float(arg)
        elif opt in ("--stop-delay"):
            stop_delay = float(arg)
        elif opt in ("--line-width"):
            line_width = float(arg)

    parser = DxfParser(open(argv[-1], 'r'))
    context = GCodeContext(z_feedrate, z_height, xy_feedrate, start_delay,
                           stop_delay, line_width, argv[-1])
    parser.parse()
    for entity in parser.entities:
        entity.get_gcode(context)
    context.generate()
 def convert_dxf_to_gcode( self, dxf_path):
     dxf_file = open( dxf_path, "r")
     
     dxf_parser = DxfParser( dxf_file)
     
     # FIXME: need better values for these details.  The following are
     # defaults taken from scribbles.py
     z_height = 0
     z_feedrate = 150
     xy_feedrate = 2000
     start_delay = 60
     stop_delay = 120
     line_width = 0.5
     
     context = GCodeContext(z_feedrate, z_height, xy_feedrate, start_delay, stop_delay, line_width, dxf_path)
     dxf_parser.parse()
     for entity in dxf_parser.entities:
         entity.get_gcode(context)
     all_gcode = context.generate( should_print=False) 
     
     gcode_model = GcodeParser().parseString( all_gcode)
     dxf_file.close()
     
     return gcode_model