def test_forces(): original_stdout = sys.stdout # keep a reference to STDOUT if Output_name.get(): sys.stdout = open(Output_name.get(), 'w') if not offset_str.get(): default_offset_str() if not matrix_str.get(): default_matrix_str() if not speed_str.get(): default_speed_str() offset = floats(offset_str.get()) matrix = floats(matrix_str.get()) speed = floats(speed_str.get()) # # main program # import graphtec import pic import optimize # offset = (5, 1) # matrix = (1, 0, 0, 1) g = graphtec.graphtec() g.start() g.set(offset=offset, matrix=matrix) g.set(speed=speed) for i in range(0, 6): for j in range(0, 5): g.set(force=1 + j + 5 * i) tx = 0.5 * j ty = 0.5 * i g.closed_path([(tx, ty), (tx + 0.3, ty), (tx + 0.3, ty + 0.3), (tx, ty + 0.3)]) g.end() if Output_name.get(): sys.stdout = original_stdout # restore STDOUT back to its original value tkMessageBox.showinfo("G2G_GUI Message", "File '%s' created" % (Output_name.get()))
if i == -1: continue cx, cy = px + vx * (i - 3 * 17) / 17.0, py + vy * (i - 3 * 17) / 17.0 g.line(cx - 0.08 * rx, cy - 0.08 * ry, cx + 0.08 * rx, cy + 0.08 * ry) for i in range(-2, 18): if i == -1: continue cx, cy = px + vx * (i + 2 * 17) / 17.0, py + vy * (i + 2 * 17) / 17.0 g.line(cx - 0.08 * rx, cy - 0.08 * ry, cx + 0.08 * rx, cy + 0.08 * ry) # # main program # g = graphtec.graphtec() g.start() g.set(offset=(4, 0.5)) g.set(speed=2) g.set(force=5) # this is for my Silhouette Cameo, to rerun this test to # verify the calibration as measured from a prior run # with matrix=(1,0,0,1) g.set(matrix=(1, 0, 0, 1)) mark(g, (3.5, 3.5), 0) mark(g, (3.5, 3.5), 45) mark(g, (3.5, 3.5), 90) mark(g, (3.5, 3.5), 135)
def main_program(): # # convert file to pic format # if not os.path.exists(Gerber_name.get()): get_input_filename() if not os.path.exists(Gerber_name.get()): tkMessageBox.showerror( "G2G_GUI ERROR", "The path provided for the input Gerber file is invalid.") return head, tail = os.path.split(Gerber_name.get()) if os.name == 'nt': temp_pdf = os.path.normpath("%s\_tmp_gerber.pdf" % (head)) temp_pic = os.path.normpath("%s\_tmp_gerber.pic" % (head)) temp_bat = os.path.normpath("%s\_tmp_gerber.bat" % (head)) else: temp_pdf = "_tmp_gerber.pdf" temp_pic = "_tmp_gerber.pic" if os.name == 'nt': if not os.path.exists(gerbv_path.get()): tkMessageBox.showerror("G2G_GUI ERROR", "The path provided for gerbv is invalid.") return if not os.path.exists(pstoedit_path.get()): tkMessageBox.showerror( "G2G_GUI ERROR", "The path provided for pstoedit is invalid.") return if os.name == 'nt': os.system( "echo \"%s\" --export=pdf --output=%s --border=0 \"%s\" > \"%s\"" % (os.path.normpath(gerbv_path.get()), temp_pdf, os.path.normpath(Gerber_name.get()), temp_bat)) os.system("echo \"%s\" -q -f pic \"%s\" \"%s\" >> \"%s\"" % (os.path.normpath( pstoedit_path.get()), temp_pdf, temp_pic, temp_bat)) os.system("\"%s\"" % temp_bat) else: os.system("%s --export=pdf --output=%s --border=0 \"%s\"" % (os.path.normpath(gerbv_path.get()), temp_pdf, os.path.normpath(Gerber_name.get()))) os.system("%s -q -f pic \"%s\" \"%s\"" % (os.path.normpath(pstoedit_path.get()), temp_pdf, temp_pic)) original_stdout = sys.stdout # keep a reference to STDOUT if Output_name.get(): sys.stdout = open(Output_name.get(), 'w') if not offset_str.get(): default_offset_str() if not border_str.get(): default_border_str() if not matrix_str.get(): default_matrix_str() if not speed_str.get(): default_speed_str() if not force_str.get(): default_force_str() if not cut_mode_str.get(): default_cut_mode_str() offset = floats(offset_str.get()) border = floats(border_str.get()) matrix = floats(matrix_str.get()) speed = floats(speed_str.get()) force = floats(force_str.get()) cut_mode = int(cut_mode_str.get()) # # main program # import graphtec import pic import optimize g = graphtec.graphtec() g.start() g.set(offset=(offset[0] + border[0] + 0.5, offset[1] + border[1] + 0.5), matrix=matrix) strokes = pic.read_pic(temp_pic) max_x, max_y = optimize.max_extent(strokes) tx, ty = 0.5, 0.5 border_path = [(-border[0], -border[1]), (max_x + border[0], -border[1]), (max_x + border[0], max_y + border[1]), (-border[0], max_y + border[1])] if cut_mode == 0: lines = optimize.optimize(strokes, border) for (s, f) in zip(speed, force): g.set(speed=s, force=f) for x in lines: g.line(*x) g.closed_path(border_path) else: for (s, f) in zip(speed, force): g.set(speed=s, force=f) for s in strokes: g.closed_path(s) g.closed_path(border_path) g.end() if Output_name.get(): sys.stdout = original_stdout # restore STDOUT back to its original value tkMessageBox.showinfo("G2G_GUI Message", "File '%s' created" % (Output_name.get()))
def main_program(): # # convert file to pic format # if not os.path.exists(Gerber_name.get()): get_input_filename() if not os.path.exists(Gerber_name.get()): tkMessageBox.showerror("G2G_GUI ERROR", "The path provided for the input Gerber file is invalid.") return head, tail = os.path.split(Gerber_name.get()) if os.name=='nt': temp_pdf = os.path.normpath("%s\_tmp_gerber.pdf" % (head)) temp_pic = os.path.normpath("%s\_tmp_gerber.pic" % (head)) temp_bat = os.path.normpath("%s\_tmp_gerber.bat" % (head)) else: temp_pdf = "_tmp_gerber.pdf" temp_pic = "_tmp_gerber.pic" if os.name=='nt': if not os.path.exists(gerbv_path.get()): tkMessageBox.showerror("G2G_GUI ERROR", "The path provided for gerbv is invalid.") return if not os.path.exists(pstoedit_path.get()): tkMessageBox.showerror("G2G_GUI ERROR", "The path provided for pstoedit is invalid.") return if os.name=='nt': os.system("echo \"%s\" --export=pdf --output=%s --border=0 \"%s\" > \"%s\"" % (os.path.normpath(gerbv_path.get()),temp_pdf,os.path.normpath(Gerber_name.get()),temp_bat)) os.system("echo \"%s\" -q -f pic \"%s\" \"%s\" >> \"%s\"" % (os.path.normpath(pstoedit_path.get()),temp_pdf,temp_pic, temp_bat)) os.system("\"%s\"" % temp_bat) else: os.system("%s --export=pdf --output=%s --border=0 \"%s\"" % (os.path.normpath(gerbv_path.get()),temp_pdf,os.path.normpath(Gerber_name.get()))) os.system("%s -q -f pic \"%s\" \"%s\"" % (os.path.normpath(pstoedit_path.get()),temp_pdf,temp_pic)) original_stdout = sys.stdout # keep a reference to STDOUT if Output_name.get(): sys.stdout = open(Output_name.get(), 'w') if not offset_str.get(): default_offset_str() if not border_str.get(): default_border_str() if not matrix_str.get(): default_matrix_str() if not speed_str.get(): default_speed_str() if not force_str.get(): default_force_str() if not cut_mode_str.get(): default_cut_mode_str() offset = floats(offset_str.get()) border = floats(border_str.get()) matrix = floats(matrix_str.get()) speed = floats(speed_str.get()) force = floats(force_str.get()) cut_mode = int(cut_mode_str.get()) # # main program # import graphtec import pic import optimize g = graphtec.graphtec() g.start() g.set(offset=(offset[0]+border[0]+0.5,offset[1]+border[1]+0.5), matrix=matrix) strokes = pic.read_pic(temp_pic) max_x,max_y = optimize.max_extent(strokes) tx,ty = 0.5,0.5 border_path = [ (-border[0], -border[1]), (max_x+border[0], -border[1]), (max_x+border[0], max_y+border[1]), (-border[0], max_y+border[1]) ] if cut_mode==0: lines = optimize.optimize(strokes, border) for (s,f) in zip(speed,force): g.set(speed=s, force=f) for x in lines: g.line(*x) g.closed_path(border_path) else: for (s,f) in zip(speed,force): g.set(speed=s, force=f) for s in strokes: g.closed_path(s) g.closed_path(border_path) g.end() if Output_name.get(): sys.stdout = original_stdout # restore STDOUT back to its original value tkMessageBox.showinfo("G2G_GUI Message", "File '%s' created" % (Output_name.get()) )
import graphtec def pads1(g): for i in range(0,20): g.path([(0,0),(0.07,0.07)]) for j in range(0,20): x = 0.1*i y = 0.008*j g.path([(x,y),(x+0.05,y)]) def pads2(g): for i in range(0,20): g.path([(0,0),(0.07,0.07)]) for j in range(0,20): x = 0.008*i y = 0.4+0.1*j g.path([(x,y),(x,y+0.05)]) g = graphtec.graphtec() g.start() g.set(offset=(1,1)) g.set(speed=1) g.set(force=1) pads1(g) pads2(g) g.end()