Code now supports python3 too
parent
8dcdf1f4ae
commit
52b4e99833
|
@ -58,7 +58,7 @@ grid_len_X += N_copies_X*margin_copies_X
|
||||||
grid_len_Y *= N_copies_Y
|
grid_len_Y *= N_copies_Y
|
||||||
grid_len_Y += N_copies_Y*margin_copies_Y
|
grid_len_Y += N_copies_Y*margin_copies_Y
|
||||||
|
|
||||||
print "PANELIZING: There will be",str(N_copies_X)+"x"+str(N_copies_Y),"copies of this board"
|
print("PANELIZING: There will be " + str(N_copies_X)+"x"+str(N_copies_Y) + " copies of this board")
|
||||||
|
|
||||||
Z_probing_data['grid_len'] = (grid_len_X,grid_len_Y)
|
Z_probing_data['grid_len'] = (grid_len_X,grid_len_Y)
|
||||||
|
|
||||||
|
@ -67,5 +67,6 @@ saveToFile(Z_probing_data,Z_PROBING_FILE)
|
||||||
pltRefresh(gcodeviewer) # Draw the figure contents, still no window
|
pltRefresh(gcodeviewer) # Draw the figure contents, still no window
|
||||||
pltShow() # Open the window showing our figure
|
pltShow() # Open the window showing our figure
|
||||||
|
|
||||||
raw_input("Press enter to exit...")
|
print("Press enter to exit...")
|
||||||
|
val = sys.stdin.readline()
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ grid_len = Z_probing_data['grid_len']
|
||||||
cy.moveZrelSafe(initial_Z_lowering_distance,F_slowMove) # Move Z towards the PCB (saves some probing time for the first coord)
|
cy.moveZrelSafe(initial_Z_lowering_distance,F_slowMove) # Move Z towards the PCB (saves some probing time for the first coord)
|
||||||
|
|
||||||
# Do the probing itself
|
# Do the probing itself
|
||||||
(x_points, y_points, probe_result, Z_offset, probe_duration) = cy.probeGrid(grid_origin, grid_len, GRID_N_POINTS, Zlift)
|
(x_points, y_points, probe_result, Z_offset, probe_duration) = cy.probeGrid(grid_origin, grid_len, GRID_N_POINTS, Zlift, F_fastMove, F_slowMove)
|
||||||
|
|
||||||
#x_points = [0.0, 17.5, 35.0, 52.5, 70.0]
|
#x_points = [0.0, 17.5, 35.0, 52.5, 70.0]
|
||||||
#y_points = [0.0, 13.333333333333334, 26.666666666666668, 40.0]
|
#y_points = [0.0, 13.333333333333334, 26.666666666666668, 40.0]
|
||||||
|
@ -62,12 +62,12 @@ Z_probing_data['probe_duration'] = probe_duration
|
||||||
saveToFile(Z_probing_data,Z_PROBING_FILE)
|
saveToFile(Z_probing_data,Z_PROBING_FILE)
|
||||||
|
|
||||||
# Show our grid
|
# Show our grid
|
||||||
print "#-------- Probing results ---------"
|
print("#-------- Probing results ---------")
|
||||||
print "x_points = ", x_points
|
print("x_points = " + str(x_points) )
|
||||||
print "y_points = ", y_points
|
print("y_points = " + str(y_points) )
|
||||||
print "probe_result = ", probe_result
|
print("probe_result = " + str(probe_result) )
|
||||||
print "probe_duration = ", probe_duration
|
print("probe_duration = " + str(probe_duration) )
|
||||||
print "#--------------------------------------"
|
print("#--------------------------------------")
|
||||||
|
|
||||||
# Display values
|
# Display values
|
||||||
|
|
||||||
|
@ -89,10 +89,10 @@ pltShowNonBlocking()
|
||||||
Z_workbed_surface = interpolate.RectBivariateSpline(y_points, x_points, probe_result)
|
Z_workbed_surface = interpolate.RectBivariateSpline(y_points, x_points, probe_result)
|
||||||
|
|
||||||
# Evaluate the interpolation in a 50x50 grid for display
|
# Evaluate the interpolation in a 50x50 grid for display
|
||||||
x_points = np.linspace(min(x_points),max(x_points),50)
|
x_points = np.linspace(min(x_points),max(x_points),100)
|
||||||
y_points = np.linspace(min(y_points),max(y_points),50)
|
y_points = np.linspace(min(y_points),max(y_points),100)
|
||||||
z_points = Z_workbed_surface(y_points,x_points)
|
z_points = Z_workbed_surface(y_points,x_points)
|
||||||
#print z_points
|
#print( str(z_points) )
|
||||||
|
|
||||||
plt.figure()
|
plt.figure()
|
||||||
plt.pcolor(x_points, y_points, z_points)
|
plt.pcolor(x_points, y_points, z_points)
|
||||||
|
@ -103,5 +103,6 @@ pltShowNonBlocking()
|
||||||
|
|
||||||
cy.close() # Close the connection with Cyclone
|
cy.close() # Close the connection with Cyclone
|
||||||
|
|
||||||
raw_input("Press enter to exit...")
|
print("Press enter to exit...")
|
||||||
|
val = sys.stdin.readline()
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ gcodeviewer = pltNewFig() # Define a new figure, this doesnt open a window by it
|
||||||
|
|
||||||
# Load the probing results (this will plot the copper level in the background too)
|
# Load the probing results (this will plot the copper level in the background too)
|
||||||
probingResults()
|
probingResults()
|
||||||
#print "Must be zero, otherwise the interpolation is wrong!:",floats(getZoffset(0,0))
|
#print("Must be zero, otherwise the interpolation is wrong!: " + floats(getZoffset(0,0)))
|
||||||
|
|
||||||
# Display the Gcode that is going to be etched
|
# Display the Gcode that is going to be etched
|
||||||
(etch_moves, travel_moves, gcode_minXY, gcode_maxXY) = gcv.view(filePath,fileName,0,showEtch,showEtch,showEtch2,showDrill,showEdge)
|
(etch_moves, travel_moves, gcode_minXY, gcode_maxXY) = gcv.view(filePath,fileName,0,showEtch,showEtch,showEtch2,showDrill,showEdge)
|
||||||
|
@ -86,9 +86,9 @@ probingResults()
|
||||||
(boardSizeX,boardSizeY,gcode_minXY_global, gcode_maxXY_global) = gcv.boardSize(filePath,fileName)
|
(boardSizeX,boardSizeY,gcode_minXY_global, gcode_maxXY_global) = gcv.boardSize(filePath,fileName)
|
||||||
|
|
||||||
# Show delimiter rectangle
|
# Show delimiter rectangle
|
||||||
x_dat = [gcode_minXY_global[0],gcode_minXY_global[0],gcode_maxXY_global[0],gcode_maxXY_global[0],gcode_minXY_global[0]]
|
#x_dat = [gcode_minXY_global[0],gcode_minXY_global[0],gcode_maxXY_global[0],gcode_maxXY_global[0],gcode_minXY_global[0]]
|
||||||
y_dat = [gcode_minXY_global[1],gcode_maxXY_global[1],gcode_maxXY_global[1],gcode_minXY_global[1],gcode_minXY_global[1]]
|
#y_dat = [gcode_minXY_global[1],gcode_maxXY_global[1],gcode_maxXY_global[1],gcode_minXY_global[1],gcode_minXY_global[1]]
|
||||||
plt.plot(x_dat,y_dat)
|
#plt.plot(x_dat,y_dat)
|
||||||
|
|
||||||
pltRefresh(gcodeviewer) # Draw the figure contents, still no window
|
pltRefresh(gcodeviewer) # Draw the figure contents, still no window
|
||||||
pltShow() # Open the window showing our figure
|
pltShow() # Open the window showing our figure
|
||||||
|
@ -140,7 +140,7 @@ initial_Z_lowering_distance = -10
|
||||||
cy.moveZrelSafe(initial_Z_lowering_distance,F_slowMove) # Move Z towards the PCB (saves some probing time for the first coord)
|
cy.moveZrelSafe(initial_Z_lowering_distance,F_slowMove) # Move Z towards the PCB (saves some probing time for the first coord)
|
||||||
|
|
||||||
Z_origin_offset = cy.probeZ()
|
Z_origin_offset = cy.probeZ()
|
||||||
print "Z offset:", Z_origin_offset
|
print("Z offset: " + str(Z_origin_offset) )
|
||||||
|
|
||||||
|
|
||||||
toolPos_X = 0
|
toolPos_X = 0
|
||||||
|
@ -170,9 +170,9 @@ def splitLongEtchMove(distance):
|
||||||
#distance = distance**0.5 # [mm]
|
#distance = distance**0.5 # [mm]
|
||||||
N_steps = int((distance/maxDistance)**0.5) # **must be** >= 1
|
N_steps = int((distance/maxDistance)**0.5) # **must be** >= 1
|
||||||
|
|
||||||
print "Splitting", distance**0.5, "mm segment into", N_steps, "steps"
|
print("Splitting " + str(distance**0.5) + "mm segment into " + str(N_steps) + " steps")
|
||||||
|
|
||||||
# print "Orig:", toolPos_X, toolPos_Y, toolPos_Z, "Dest:", X_dest, Y_dest, Z_dest
|
# print("Orig: " + (toolPos_X,toolPos_Y,toolPos_Z) + " Dest: " + (X_dest, Y_dest, Z_dest))
|
||||||
|
|
||||||
X_step = (X_dest-toolPos_X)/float(N_steps)
|
X_step = (X_dest-toolPos_X)/float(N_steps)
|
||||||
Y_step = (Y_dest-toolPos_Y)/float(N_steps)
|
Y_step = (Y_dest-toolPos_Y)/float(N_steps)
|
||||||
|
@ -189,7 +189,7 @@ def splitLongEtchMove(distance):
|
||||||
cy.moveXYZ(X_dest_tmp, Y_dest_tmp, Z_real, F_dest_tmp)
|
cy.moveXYZ(X_dest_tmp, Y_dest_tmp, Z_real, F_dest_tmp)
|
||||||
toolPos_refresh(X_dest_tmp, Y_dest_tmp, etching=1)
|
toolPos_refresh(X_dest_tmp, Y_dest_tmp, etching=1)
|
||||||
|
|
||||||
# print "Move:",X_dest_tmp, Y_dest_tmp, Z_dest_tmp
|
# print("Move: " + (X_dest_tmp, Y_dest_tmp, Z_dest_tmp) )
|
||||||
|
|
||||||
toolPos_X = X_dest_tmp
|
toolPos_X = X_dest_tmp
|
||||||
toolPos_Y = Y_dest_tmp
|
toolPos_Y = Y_dest_tmp
|
||||||
|
@ -197,7 +197,8 @@ def splitLongEtchMove(distance):
|
||||||
toolPos_F = F_dest_tmp
|
toolPos_F = F_dest_tmp
|
||||||
|
|
||||||
|
|
||||||
raw_input("Turn on the spindle and press enter to begin...")
|
print("Turn on the spindle and press enter to begin...")
|
||||||
|
val = sys.stdin.readline()
|
||||||
|
|
||||||
def doPath(X_offset=0, Y_offset=0):
|
def doPath(X_offset=0, Y_offset=0):
|
||||||
global toolPos_X, toolPos_Y, toolPos_Z, toolPos_F, X_dest, Y_dest, Z_dest, F_dest
|
global toolPos_X, toolPos_Y, toolPos_Z, toolPos_F, X_dest, Y_dest, Z_dest, F_dest
|
||||||
|
@ -208,7 +209,7 @@ def doPath(X_offset=0, Y_offset=0):
|
||||||
X_dest = path[0][0]+X_offset
|
X_dest = path[0][0]+X_offset
|
||||||
Y_dest = path[0][1]+Y_offset
|
Y_dest = path[0][1]+Y_offset
|
||||||
F_dest = F_fastMove
|
F_dest = F_fastMove
|
||||||
print " Traveling to:", str([X_dest, Y_dest]), "at Z:", Z_global_offset+Zlift_milling
|
print(" Traveling to: " + str([X_dest, Y_dest]) + " at Z:" + str(Z_global_offset+Zlift_milling) )
|
||||||
cy.moveXY(X_dest, Y_dest, F_dest)
|
cy.moveXY(X_dest, Y_dest, F_dest)
|
||||||
toolPos_draw(X_dest, Y_dest, etching=0)
|
toolPos_draw(X_dest, Y_dest, etching=0)
|
||||||
Z_dest = path[0][2]
|
Z_dest = path[0][2]
|
||||||
|
@ -217,14 +218,14 @@ def doPath(X_offset=0, Y_offset=0):
|
||||||
else:
|
else:
|
||||||
F_dest = path[0][3] # We set the original speed if it is etching/drill
|
F_dest = path[0][3] # We set the original speed if it is etching/drill
|
||||||
cy.moveZ(Z_dest+Z_origin_offset+getZoffset(X_dest, Y_dest)+Z_global_offset,F_dest)
|
cy.moveZ(Z_dest+Z_origin_offset+getZoffset(X_dest, Y_dest)+Z_global_offset,F_dest)
|
||||||
# print "Speed:",F_dest
|
# print("Speed:",F_dest)
|
||||||
print " Etching at Z:",Z_dest+Z_global_offset
|
print(" Etching at Z: " + str(Z_dest+Z_global_offset) )
|
||||||
toolPos_X = X_dest
|
toolPos_X = X_dest
|
||||||
toolPos_Y = Y_dest
|
toolPos_Y = Y_dest
|
||||||
toolPos_Z = Z_dest # Not sure..
|
toolPos_Z = Z_dest # Not sure..
|
||||||
toolPos_F = F_dest
|
toolPos_F = F_dest
|
||||||
|
|
||||||
# print path
|
# print(path)
|
||||||
|
|
||||||
for coord in path[1:] :
|
for coord in path[1:] :
|
||||||
X_dest = coord[0]+X_offset
|
X_dest = coord[0]+X_offset
|
||||||
|
@ -236,11 +237,11 @@ def doPath(X_offset=0, Y_offset=0):
|
||||||
if distance >= maxDistance :
|
if distance >= maxDistance :
|
||||||
splitLongEtchMove(distance)
|
splitLongEtchMove(distance)
|
||||||
if distance < minDistance and (Z_dest-toolPos_Z)**2 < 0.001**2 : # Make sure it is not a Z movement
|
if distance < minDistance and (Z_dest-toolPos_Z)**2 < 0.001**2 : # Make sure it is not a Z movement
|
||||||
print "Ignoring", distance**0.5, "mm segment!"
|
print("Ignoring " + str(distance**0.5) + "mm segment!")
|
||||||
continue
|
continue
|
||||||
Z_real = Z_dest+Z_origin_offset+getZoffset(X_dest, Y_dest)+Z_global_offset
|
Z_real = Z_dest+Z_origin_offset+getZoffset(X_dest, Y_dest)+Z_global_offset
|
||||||
cy.moveXYZ(X_dest, Y_dest, Z_real, F_dest)
|
cy.moveXYZ(X_dest, Y_dest, Z_real, F_dest)
|
||||||
# print "Coords: Speed:",F_dest
|
# print("Coords: Speed: " + str(F_dest))
|
||||||
toolPos_refresh(X_dest, Y_dest, etching=1)
|
toolPos_refresh(X_dest, Y_dest, etching=1)
|
||||||
|
|
||||||
toolPos_X = X_dest
|
toolPos_X = X_dest
|
||||||
|
@ -256,5 +257,6 @@ for x_i in range(N_copies_X):
|
||||||
cy.homeZXY() # It is important to send a blocking command in the end
|
cy.homeZXY() # It is important to send a blocking command in the end
|
||||||
cy.close() # Close the connection with Cyclone
|
cy.close() # Close the connection with Cyclone
|
||||||
|
|
||||||
raw_input("Done. Press enter to exit...")
|
print("Done. Press enter to exit...")
|
||||||
|
val = sys.stdin.readline()
|
||||||
|
|
||||||
|
|
|
@ -58,31 +58,31 @@ plt.hold(True)
|
||||||
plt.title("Original Gcode")
|
plt.title("Original Gcode")
|
||||||
plt.axis('equal') # 1:1 aspect ratio
|
plt.axis('equal') # 1:1 aspect ratio
|
||||||
|
|
||||||
print "\n Loading etch..."
|
print("\n Loading etch...")
|
||||||
gcode_file = filePath+fileName+"_etch.gcode"
|
gcode_file = filePath+fileName+"_etch.gcode"
|
||||||
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
||||||
plotPoints(etch_moves, etch_color, etch_diam)
|
plotPoints(etch_moves, etch_color, etch_diam)
|
||||||
plotPoints(travel_moves, travel_color, linewidth_travel_move)
|
plotPoints(travel_moves, travel_color, linewidth_travel_move)
|
||||||
|
|
||||||
print "\n Loading etch (2nd pass)..."
|
print("\n Loading etch (2nd pass)...")
|
||||||
gcode_file = filePath+fileName+"_etch2pass.gcode"
|
gcode_file = filePath+fileName+"_etch2pass.gcode"
|
||||||
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
||||||
plotPoints(etch_moves, etch2pass_color, etch2pass_diam)
|
plotPoints(etch_moves, etch2pass_color, etch2pass_diam)
|
||||||
plotPoints(travel_moves, travel_color, linewidth_travel_move)
|
plotPoints(travel_moves, travel_color, linewidth_travel_move)
|
||||||
|
|
||||||
print "\n Loading etch (3nd pass)..."
|
print("\n Loading etch (3nd pass)...")
|
||||||
gcode_file = filePath+fileName+"_etch3pass.gcode"
|
gcode_file = filePath+fileName+"_etch3pass.gcode"
|
||||||
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
||||||
plotPoints(etch_moves, etch3pass_color, etch3pass_diam)
|
plotPoints(etch_moves, etch3pass_color, etch3pass_diam)
|
||||||
plotPoints(travel_moves, travel_color, linewidth_travel_move)
|
plotPoints(travel_moves, travel_color, linewidth_travel_move)
|
||||||
|
|
||||||
print "\n Loading drill..."
|
print("\n Loading drill...")
|
||||||
gcode_file = filePath+fileName+"_drill.gcode"
|
gcode_file = filePath+fileName+"_drill.gcode"
|
||||||
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
||||||
plotPoints(etch_moves, drill_color, drill_diam)
|
plotPoints(etch_moves, drill_color, drill_diam)
|
||||||
plotPoints(travel_moves, travel_color, linewidth_travel_move)
|
plotPoints(travel_moves, travel_color, linewidth_travel_move)
|
||||||
|
|
||||||
print "\n Loading edge..."
|
print("\n Loading edge...")
|
||||||
gcode_file = filePath+fileName+"_edge.gcode"
|
gcode_file = filePath+fileName+"_edge.gcode"
|
||||||
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
||||||
plotPoints(etch_moves, edge_color, edge_diam)
|
plotPoints(etch_moves, edge_color, edge_diam)
|
||||||
|
@ -95,35 +95,35 @@ plt.hold(True)
|
||||||
plt.title("Optimized (closest neighbour)")
|
plt.title("Optimized (closest neighbour)")
|
||||||
plt.axis('equal') # 1:1 aspect ratio
|
plt.axis('equal') # 1:1 aspect ratio
|
||||||
|
|
||||||
print "\n Loading etch..."
|
print("\n Loading etch...")
|
||||||
gcode_file = filePath+fileName+"_etch.gcode"
|
gcode_file = filePath+fileName+"_etch.gcode"
|
||||||
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
||||||
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
||||||
plotPoints(etch_moves, etch_color, etch_diam)
|
plotPoints(etch_moves, etch_color, etch_diam)
|
||||||
plotPoints(travel_moves, travel_color, linewidth_travel_move)
|
plotPoints(travel_moves, travel_color, linewidth_travel_move)
|
||||||
|
|
||||||
print "\n Loading etch (2nd pass)..."
|
print("\n Loading etch (2nd pass)...")
|
||||||
gcode_file = filePath+fileName+"_etch2pass.gcode"
|
gcode_file = filePath+fileName+"_etch2pass.gcode"
|
||||||
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
||||||
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
||||||
plotPoints(etch_moves, etch2pass_color, etch2pass_diam)
|
plotPoints(etch_moves, etch2pass_color, etch2pass_diam)
|
||||||
plotPoints(travel_moves, travel_color, linewidth_travel_move)
|
plotPoints(travel_moves, travel_color, linewidth_travel_move)
|
||||||
|
|
||||||
print "\n Loading etch (3nd pass)..."
|
print("\n Loading etch (3nd pass)...")
|
||||||
gcode_file = filePath+fileName+"_etch3pass.gcode"
|
gcode_file = filePath+fileName+"_etch3pass.gcode"
|
||||||
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
||||||
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
||||||
plotPoints(etch_moves, etch3pass_color, etch3pass_diam)
|
plotPoints(etch_moves, etch3pass_color, etch3pass_diam)
|
||||||
plotPoints(travel_moves, travel_color, linewidth_travel_move)
|
plotPoints(travel_moves, travel_color, linewidth_travel_move)
|
||||||
|
|
||||||
print "\n Loading drill..."
|
print("\n Loading drill...")
|
||||||
gcode_file = filePath+fileName+"_drill.gcode"
|
gcode_file = filePath+fileName+"_drill.gcode"
|
||||||
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
||||||
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
||||||
plotPoints(etch_moves, drill_color, drill_diam)
|
plotPoints(etch_moves, drill_color, drill_diam)
|
||||||
plotPoints(travel_moves, travel_color, linewidth_travel_move)
|
plotPoints(travel_moves, travel_color, linewidth_travel_move)
|
||||||
|
|
||||||
print "\n Loading edge..."
|
print("\n Loading edge...")
|
||||||
gcode_file = filePath+fileName+"_edge.gcode"
|
gcode_file = filePath+fileName+"_edge.gcode"
|
||||||
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
(etch_moves, travel_moves, gcode_originXY, grid_sizeXY) = gcp.parseGcodeRaw(gcode_file)
|
||||||
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
||||||
|
@ -134,5 +134,6 @@ plotPoints(travel_moves, travel_color, linewidth_travel_move)
|
||||||
plt.ion() # Enable real-time plotting to avoid blocking behaviour for pyplot
|
plt.ion() # Enable real-time plotting to avoid blocking behaviour for pyplot
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
raw_input("Press enter to exit...")
|
print("Press enter to exit...")
|
||||||
|
val = sys.stdin.readline()
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ from datetime import datetime
|
||||||
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from helper import *
|
from CycloneHost.helper import *
|
||||||
# End modules
|
# End modules
|
||||||
|
|
||||||
# Begin configuration. It is overwritten when running setup(baudrate, device)
|
# Begin configuration. It is overwritten when running setup(baudrate, device)
|
||||||
|
@ -60,39 +60,39 @@ def connect(baudrate, device, emulate = 0):
|
||||||
global CNC_Machine, Emulate
|
global CNC_Machine, Emulate
|
||||||
BAUDRATE = baudrate
|
BAUDRATE = baudrate
|
||||||
DEVICE = device
|
DEVICE = device
|
||||||
print "Connecting to Cyclone..."
|
print("Connecting to Cyclone...")
|
||||||
if emulate == 0:
|
if emulate == 0:
|
||||||
CNC_Machine = serial.Serial(DEVICE, BAUDRATE, timeout = serial_timeout)
|
CNC_Machine = serial.Serial(DEVICE, BAUDRATE, timeout = serial_timeout)
|
||||||
Emulate = 0
|
Emulate = 0
|
||||||
else:
|
else:
|
||||||
Emulate = 1
|
Emulate = 1
|
||||||
print "EMULATING MACHINE!"
|
print("EMULATING MACHINE!")
|
||||||
print "Serial port opened, checking connection..."
|
print("Serial port opened, checking connection...")
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
checkConnection()
|
checkConnection()
|
||||||
print "Connected!"
|
print("Connected!")
|
||||||
|
|
||||||
def flushRecvBuffer(): # We could also use flushInput(), but showing the data that is being discarded is useful for debugging
|
def flushRecvBuffer(): # We could also use flushInput(), but showing the data that is being discarded is useful for debugging
|
||||||
if Emulate:
|
if Emulate:
|
||||||
return
|
return
|
||||||
while CNC_Machine.inWaiting() > 0:
|
while CNC_Machine.inWaiting() > 0:
|
||||||
response = CNC_Machine.readline()
|
response = CNC_Machine.readline()
|
||||||
# if response != '': print "IGNO: ", response
|
# if response != '': print("IGNO: " + response)
|
||||||
time.sleep(seconds_wait) # Wait some milliseconds between attempts
|
time.sleep(seconds_wait) # Wait some milliseconds between attempts
|
||||||
|
|
||||||
def sendLine(line):
|
def sendLine(line):
|
||||||
if Emulate == 0:
|
if Emulate == 0:
|
||||||
flushRecvBuffer()
|
flushRecvBuffer()
|
||||||
CNC_Machine.write(line)
|
CNC_Machine.write(line)
|
||||||
# print "SENT: ", line
|
# print("SENT: " + line)
|
||||||
|
|
||||||
def recvLine():
|
def recvLine():
|
||||||
if Emulate:
|
if Emulate:
|
||||||
response = "ok\n" # Asume OK
|
response = "ok\n" # Asume OK
|
||||||
else:
|
else:
|
||||||
response = CNC_Machine.readline()
|
response = CNC_Machine.readline()
|
||||||
# if response != '': print "RECV: ", response
|
# if response != '': print("RECV: " + response)
|
||||||
# else: print "RECV: Receive timed out!"
|
# else: print("RECV: Receive timed out!")
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def recvOK():
|
def recvOK():
|
||||||
|
@ -102,19 +102,19 @@ def recvOK():
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def waitForOK(command="",timeoutResend=30): # This is a blocking function
|
def waitForOK(command="",timeoutResend=30): # This is a blocking function
|
||||||
# print "Waiting for confirmation"
|
# print("Waiting for confirmation")
|
||||||
i = 0
|
i = 0
|
||||||
cmnd = command[:3].lower()
|
cmnd = command[:3].lower()
|
||||||
timeoutResend = float(timeoutResend)
|
timeoutResend = float(timeoutResend)
|
||||||
#timeoutResend = 5.0 # Resend command every 5 seconds, error recovery
|
#timeoutResend = 5.0 # Resend command every 5 seconds, error recovery
|
||||||
#if cmnd == "g28": timeoutResend = 60.0 # Homing moves will take more than 5 seconds
|
#if cmnd == "g28": timeoutResend = 60.0 # Homing moves will take more than 5 seconds
|
||||||
i_timeout = int(timeoutResend/float(serial_timeout+seconds_wait))
|
i_timeout = int(timeoutResend/float(serial_timeout+seconds_wait))
|
||||||
# print "i_timeout",i_timeout
|
# print("i_timeout = " + str(i_timeout))
|
||||||
while recvOK() != 1:
|
while recvOK() != 1:
|
||||||
print " Checking again... timeout:",i_timeout
|
print(" Checking again... timeout: " + str(i_timeout) )
|
||||||
time.sleep(seconds_wait) # Wait some milliseconds between attempts
|
time.sleep(seconds_wait) # Wait some milliseconds between attempts
|
||||||
if cmnd != "g30" and i >= i_timeout: # WARNING: Commands that take >5s may have problems here!
|
if cmnd != "g30" and i >= i_timeout: # WARNING: Commands that take >5s may have problems here!
|
||||||
print " WATCHOUT! RESENDING:",command
|
print(" WATCHOUT! RESENDING: " + str(command) )
|
||||||
sendLine(command)
|
sendLine(command)
|
||||||
i = 0
|
i = 0
|
||||||
else:
|
else:
|
||||||
|
@ -125,7 +125,7 @@ def sendCommand(command,timeoutResend=15): # Send command and wait for OK
|
||||||
waitForOK(command,timeoutResend)
|
waitForOK(command,timeoutResend)
|
||||||
|
|
||||||
def checkConnection():
|
def checkConnection():
|
||||||
# print "Checking the connection..."
|
# print("Checking the connection...")
|
||||||
sendLine("G21\n") # We check the connection setting millimiters as the unit and waiting for the OK response
|
sendLine("G21\n") # We check the connection setting millimiters as the unit and waiting for the OK response
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
while recvOK() != 1:
|
while recvOK() != 1:
|
||||||
|
@ -134,7 +134,7 @@ def checkConnection():
|
||||||
|
|
||||||
def homeZXY():
|
def homeZXY():
|
||||||
global lastDrillPos
|
global lastDrillPos
|
||||||
print "Homing all axis..."
|
print("Homing all axis...")
|
||||||
timeoutResend=30
|
timeoutResend=30
|
||||||
sendCommand("G28 Z0\n",timeoutResend) # move Z to min endstop
|
sendCommand("G28 Z0\n",timeoutResend) # move Z to min endstop
|
||||||
sendCommand("G28 X0\n",timeoutResend) # move X to min endstop
|
sendCommand("G28 X0\n",timeoutResend) # move X to min endstop
|
||||||
|
@ -142,13 +142,13 @@ def homeZXY():
|
||||||
if Emulate:
|
if Emulate:
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
lastDrillPos = [0,0,0]
|
lastDrillPos = [0,0,0]
|
||||||
print "Done homing"
|
print("Done homing")
|
||||||
|
|
||||||
def moveXYZ(X, Y, Z, F):
|
def moveXYZ(X, Y, Z, F):
|
||||||
global lastDrillPos
|
global lastDrillPos
|
||||||
# print "Moving to:"
|
# print("Moving to:")
|
||||||
if F <= 0:
|
if F <= 0:
|
||||||
print "ERROR: F <= 0"
|
print("ERROR: F <= 0")
|
||||||
sendCommand("G1 X"+floats(X)+" Y"+floats(Y)+" Z"+floats(Z)+" F"+floats(F)+"\n")
|
sendCommand("G1 X"+floats(X)+" Y"+floats(Y)+" Z"+floats(Z)+" F"+floats(F)+"\n")
|
||||||
if Emulate:
|
if Emulate:
|
||||||
dist = ((X-lastDrillPos[0])**2+(Y-lastDrillPos[1])**2+(Z-lastDrillPos[2])**2)**0.5 # [mm]
|
dist = ((X-lastDrillPos[0])**2+(Y-lastDrillPos[1])**2+(Z-lastDrillPos[2])**2)**0.5 # [mm]
|
||||||
|
@ -158,9 +158,9 @@ def moveXYZ(X, Y, Z, F):
|
||||||
|
|
||||||
def moveXY(X, Y, F):
|
def moveXY(X, Y, F):
|
||||||
global lastDrillPos
|
global lastDrillPos
|
||||||
# print "Moving to:"
|
# print("Moving to:")
|
||||||
if F <= 0:
|
if F <= 0:
|
||||||
print "ERROR: F <= 0"
|
print("ERROR: F <= 0")
|
||||||
sendCommand("G1 X"+floats(X)+" Y"+floats(Y)+" F"+floats(F)+"\n")
|
sendCommand("G1 X"+floats(X)+" Y"+floats(Y)+" F"+floats(F)+"\n")
|
||||||
if Emulate:
|
if Emulate:
|
||||||
dist = ((X-lastDrillPos[0])**2+(Y-lastDrillPos[1])**2)**0.5 # [mm]
|
dist = ((X-lastDrillPos[0])**2+(Y-lastDrillPos[1])**2)**0.5 # [mm]
|
||||||
|
@ -170,9 +170,9 @@ def moveXY(X, Y, F):
|
||||||
|
|
||||||
def moveZ(Z, F):
|
def moveZ(Z, F):
|
||||||
global lastDrillPos
|
global lastDrillPos
|
||||||
# print "Moving Z absolute:"
|
# print("Moving Z absolute:")
|
||||||
if F <= 0:
|
if F <= 0:
|
||||||
print "ERROR: F <= 0"
|
print("ERROR: F <= 0")
|
||||||
sendCommand("G1 Z"+floats(Z)+" F"+floats(F)+"\n")
|
sendCommand("G1 Z"+floats(Z)+" F"+floats(F)+"\n")
|
||||||
if Emulate:
|
if Emulate:
|
||||||
dist = abs(Z-lastDrillPos[2]) # [mm]
|
dist = abs(Z-lastDrillPos[2]) # [mm]
|
||||||
|
@ -182,9 +182,9 @@ def moveZ(Z, F):
|
||||||
|
|
||||||
def moveZrel(Z, F):
|
def moveZrel(Z, F):
|
||||||
global lastDrillPos
|
global lastDrillPos
|
||||||
# print "Moving Z relative:"
|
# print("Moving Z relative:")
|
||||||
if F <= 0:
|
if F <= 0:
|
||||||
print "ERROR: F <= 0"
|
print("ERROR: F <= 0")
|
||||||
sendCommand("G91\n") # Set relative positioning
|
sendCommand("G91\n") # Set relative positioning
|
||||||
sendCommand("G1 Z"+floats(Z)+" F"+floats(F)+"\n")
|
sendCommand("G1 Z"+floats(Z)+" F"+floats(F)+"\n")
|
||||||
if Emulate:
|
if Emulate:
|
||||||
|
@ -196,23 +196,23 @@ def moveZrel(Z, F):
|
||||||
|
|
||||||
def moveZrelSafe(Z, F):
|
def moveZrelSafe(Z, F):
|
||||||
if F <= 0:
|
if F <= 0:
|
||||||
print "ERROR: F <= 0"
|
print("ERROR: F <= 0")
|
||||||
print "Moving Z", Z, "mm safely..."
|
print("Moving Z " + str(Z) + "mm safely...")
|
||||||
sendCommand("M121\n") # Enable endstops (for protection! usually it should **NOT** hit neither the endstop nor the PCB)
|
sendCommand("M121\n") # Enable endstops (for protection! usually it should **NOT** hit neither the endstop nor the PCB)
|
||||||
moveZrel(Z, F)
|
moveZrel(Z, F)
|
||||||
dist = abs(Z) # [mm]
|
dist = abs(Z) # [mm]
|
||||||
speed = float(F)/60.0 # [mm/s]
|
speed = float(F)/60.0 # [mm/s]
|
||||||
wait = float(dist)/speed # [s]
|
wait = float(dist)/speed # [s]
|
||||||
time.sleep(wait) # Wait for the movement to finish, this way the M121 command is effective
|
time.sleep(wait) # Wait for the movement to finish, this way the M121 command is effective
|
||||||
print " Done moving Z!"
|
print(" Done moving Z!")
|
||||||
sendCommand("M120\n") # Disable endstops (we only use them for homing)
|
sendCommand("M120\n") # Disable endstops (we only use them for homing)
|
||||||
|
|
||||||
def probeZ():
|
def probeZ():
|
||||||
print "Probing Z"
|
print("Probing Z")
|
||||||
sendLine("G30\n") # Launch probe command
|
sendLine("G30\n") # Launch probe command
|
||||||
response = recvLine() # Read the response, it is a variable run time so we may need to make multiple attempts
|
response = recvLine() # Read the response, it is a variable run time so we may need to make multiple attempts
|
||||||
while response == '':
|
while response == '':
|
||||||
#print "."
|
#print(".")
|
||||||
time.sleep(seconds_wait) # Wait some milliseconds between attempts
|
time.sleep(seconds_wait) # Wait some milliseconds between attempts
|
||||||
response = recvLine()
|
response = recvLine()
|
||||||
if Emulate:
|
if Emulate:
|
||||||
|
@ -220,7 +220,7 @@ def probeZ():
|
||||||
response_vals = response.split() # Split the response (i.e. "ok Z1.23")
|
response_vals = response.split() # Split the response (i.e. "ok Z1.23")
|
||||||
if response_vals[0][:2].lower() == OK_response.lower():
|
if response_vals[0][:2].lower() == OK_response.lower():
|
||||||
Zres = response_vals[1][2:] # Ignore the "Z:" and read the coordinate value
|
Zres = response_vals[1][2:] # Ignore the "Z:" and read the coordinate value
|
||||||
print "Result is Z=",Zres
|
print("Result is Z = " + str(Zres))
|
||||||
return float(Zres)
|
return float(Zres)
|
||||||
return 400 # Error case, don't worry: it has never happened :)
|
return 400 # Error case, don't worry: it has never happened :)
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ def close():
|
||||||
if Emulate == 0:
|
if Emulate == 0:
|
||||||
CNC_Machine.close() # Close the serial port connection
|
CNC_Machine.close() # Close the serial port connection
|
||||||
|
|
||||||
def probeGrid(grid_origin, grid_len, grid_N, Zlift, F_fastMove = 400, F_slowMove = 100):
|
def probeGrid(grid_origin, grid_len, grid_N, Zlift, F_fastMove, F_slowMove):
|
||||||
grid_origin_X = float(grid_origin[0]) # Initial point of the grid [mm]
|
grid_origin_X = float(grid_origin[0]) # Initial point of the grid [mm]
|
||||||
grid_origin_Y = float(grid_origin[1])
|
grid_origin_Y = float(grid_origin[1])
|
||||||
|
|
||||||
|
@ -252,10 +252,10 @@ def probeGrid(grid_origin, grid_len, grid_N, Zlift, F_fastMove = 400, F_slowMove
|
||||||
|
|
||||||
# Show our grid (initialised as zeros)
|
# Show our grid (initialised as zeros)
|
||||||
for row in probe_result:
|
for row in probe_result:
|
||||||
print row
|
print(str(row))
|
||||||
|
|
||||||
print "Probing begins!"
|
print("Probing begins!")
|
||||||
print "WARNING: Keep an eye on the machine, unplug if something goes wrong!"
|
print("WARNING: Keep an eye on the machine, unplug if something goes wrong!")
|
||||||
beginTime = datetime.now() # Store current time in a variable, will be used to measure duration of the probing
|
beginTime = datetime.now() # Store current time in a variable, will be used to measure duration of the probing
|
||||||
|
|
||||||
# Move to grid's origin
|
# Move to grid's origin
|
||||||
|
@ -274,7 +274,7 @@ def probeGrid(grid_origin, grid_len, grid_N, Zlift, F_fastMove = 400, F_slowMove
|
||||||
|
|
||||||
# Once we have all the points, we set the origin as (0,0) and offset the rest of values
|
# Once we have all the points, we set the origin as (0,0) and offset the rest of values
|
||||||
Z_offset = probe_result[0][0]
|
Z_offset = probe_result[0][0]
|
||||||
print "The origin Z height is", Z_offset
|
print("The origin Z height is " + str(Z_offset))
|
||||||
probe_result = [[elem - Z_offset for elem in row] for row in probe_result]
|
probe_result = [[elem - Z_offset for elem in row] for row in probe_result]
|
||||||
|
|
||||||
# Return to the grid's origin
|
# Return to the grid's origin
|
||||||
|
@ -282,7 +282,7 @@ def probeGrid(grid_origin, grid_len, grid_N, Zlift, F_fastMove = 400, F_slowMove
|
||||||
moveXY(grid_origin_X, grid_origin_Y, F_fastMove) # Move to grid's origin
|
moveXY(grid_origin_X, grid_origin_Y, F_fastMove) # Move to grid's origin
|
||||||
|
|
||||||
duration = datetime.now() - beginTime
|
duration = datetime.now() - beginTime
|
||||||
print "Probing duration:", str(duration)
|
print("Probing duration:" + str(duration))
|
||||||
duration_s = duration.total_seconds()
|
duration_s = duration.total_seconds()
|
||||||
|
|
||||||
return (x_points, y_points, probe_result, Z_offset, duration_s)
|
return (x_points, y_points, probe_result, Z_offset, duration_s)
|
||||||
|
|
|
@ -84,7 +84,7 @@ def parseGcodeRaw(filePath, etch_definition = 0, close_shapes = 0): # Gcode pars
|
||||||
totalLines = len(lines)
|
totalLines = len(lines)
|
||||||
for line in lines:# check each line
|
for line in lines:# check each line
|
||||||
currentLine = currentLine + 1
|
currentLine = currentLine + 1
|
||||||
#print "({0:.1f}%)".format((currentLine / totalLines)*100), "Reading:", line[:-1]
|
#print("({0:.1f}%)".format((currentLine / totalLines)*100), "Reading:", line[:-1])
|
||||||
|
|
||||||
X_start = X_dest
|
X_start = X_dest
|
||||||
Y_start = Y_dest
|
Y_start = Y_dest
|
||||||
|
@ -155,11 +155,11 @@ def parseGcodeRaw(filePath, etch_definition = 0, close_shapes = 0): # Gcode pars
|
||||||
gcode_maxXY = [X_max, Y_max]
|
gcode_maxXY = [X_max, Y_max]
|
||||||
gcode_minXY = [X_min, Y_min]
|
gcode_minXY = [X_min, Y_min]
|
||||||
|
|
||||||
print "Gcode XY min:",str(gcode_minXY)
|
print("Gcode XY min: " + str(gcode_minXY))
|
||||||
print "Gcode XY max:",str(gcode_maxXY)
|
print("Gcode XY max: " + str(gcode_maxXY))
|
||||||
|
|
||||||
else :
|
else :
|
||||||
print "No etch moves found!"
|
print("No etch moves found!")
|
||||||
return etch_moves, travel_moves, [0,0], [0,0]
|
return etch_moves, travel_moves, [0,0], [0,0]
|
||||||
gcode.close()
|
gcode.close()
|
||||||
return etch_moves, travel_moves, gcode_minXY, gcode_maxXY
|
return etch_moves, travel_moves, gcode_minXY, gcode_maxXY
|
||||||
|
@ -179,7 +179,7 @@ def optimize(etch_moves_in, origin=[0,0], travel_height = 5): # Optimizes the to
|
||||||
minDistance = 1e9
|
minDistance = 1e9
|
||||||
|
|
||||||
while len(etch_moves_in) > 0 : # While there are remaining moves
|
while len(etch_moves_in) > 0 : # While there are remaining moves
|
||||||
closest = [1e9,1e9]
|
closest = 1e9
|
||||||
distance = 1e9
|
distance = 1e9
|
||||||
closestMove_i = 0
|
closestMove_i = 0
|
||||||
i = 0
|
i = 0
|
||||||
|
@ -197,13 +197,13 @@ def optimize(etch_moves_in, origin=[0,0], travel_height = 5): # Optimizes the to
|
||||||
closest = distance
|
closest = distance
|
||||||
closestMove_i = i
|
closestMove_i = i
|
||||||
reverse = 1 # Flag set to reverse the path
|
reverse = 1 # Flag set to reverse the path
|
||||||
#print "Using a reverse path did optimize!"
|
#print("Using a reverse path did optimize!")
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
path = etch_moves_in[closestMove_i] # Select the closest that has been found
|
path = etch_moves_in[closestMove_i] # Select the closest that has been found
|
||||||
if reverse :
|
if reverse :
|
||||||
path = path[::-1] # If the closest one was from the end, we reverse the path
|
path = path[::-1] # If the closest one was from the end, we reverse the path
|
||||||
#print "Reverse!"
|
#print("Reverse!")
|
||||||
|
|
||||||
firstPoint = path[0]
|
firstPoint = path[0]
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ def optimize(etch_moves_in, origin=[0,0], travel_height = 5): # Optimizes the to
|
||||||
travel_moves.append([toolPosition, [firstPoint[0], firstPoint[1], travel_height, firstPoint[3]] ]) # Travel to the initial point of the etching
|
travel_moves.append([toolPosition, [firstPoint[0], firstPoint[1], travel_height, firstPoint[3]] ]) # Travel to the initial point of the etching
|
||||||
else :
|
else :
|
||||||
travel_moves.append([toolPosition, firstPoint]) # Travel to the initial point of the etching (without lifting)
|
travel_moves.append([toolPosition, firstPoint]) # Travel to the initial point of the etching (without lifting)
|
||||||
print "Joining etching paths!" # TODO: This needs to join also the paths in etch_moves! otherwise it makes no difference!
|
print("Joining etching paths!") # TODO: This needs to join also the paths in etch_moves! otherwise it makes no difference!
|
||||||
|
|
||||||
if distance < minDistance :
|
if distance < minDistance :
|
||||||
minDistance = distance
|
minDistance = distance
|
||||||
|
@ -221,7 +221,7 @@ def optimize(etch_moves_in, origin=[0,0], travel_height = 5): # Optimizes the to
|
||||||
|
|
||||||
toolPosition = path[-1] # Set our endpoint as the initial one for the next move
|
toolPosition = path[-1] # Set our endpoint as the initial one for the next move
|
||||||
|
|
||||||
print "Minimum XY travel distance:", minDistance**0.5
|
print("Minimum XY travel distance: " + str(minDistance**0.5) )
|
||||||
|
|
||||||
travel_moves.append([toolPosition, [origin[0], origin[1], travel_height, 10]]) # Return to the origin
|
travel_moves.append([toolPosition, [origin[0], origin[1], travel_height, 10]]) # Return to the origin
|
||||||
return etch_moves, travel_moves
|
return etch_moves, travel_moves
|
||||||
|
|
|
@ -18,7 +18,7 @@ import numpy as np
|
||||||
from scipy import interpolate
|
from scipy import interpolate
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
import GcodeParser as gcp
|
import CycloneHost.GcodeParser as gcp
|
||||||
# End modules
|
# End modules
|
||||||
|
|
||||||
def plotPoints(path_list, color, linewidth): # Thanks to pprzemek (http://stackoverflow.com/questions/2282727/draw-points-using-matplotlib-pyplot-x1-y1-x2-y2)
|
def plotPoints(path_list, color, linewidth): # Thanks to pprzemek (http://stackoverflow.com/questions/2282727/draw-points-using-matplotlib-pyplot-x1-y1-x2-y2)
|
||||||
|
@ -85,7 +85,7 @@ def view(filePath,fileName,showAll=0,showEtch=0,showEtch2=0,showEtch3=0,showDril
|
||||||
plt.hold(True)
|
plt.hold(True)
|
||||||
|
|
||||||
if showAll or showEtch:
|
if showAll or showEtch:
|
||||||
print "\n Loading etch..."
|
print("\n Loading etch...")
|
||||||
gcode_file = filePath+fileName+"_etch.gcode"
|
gcode_file = filePath+fileName+"_etch.gcode"
|
||||||
(etch_moves, travel_moves, gcode_minXY, gcode_maxXY) = gcp.parseGcodeRaw(gcode_file)
|
(etch_moves, travel_moves, gcode_minXY, gcode_maxXY) = gcp.parseGcodeRaw(gcode_file)
|
||||||
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
||||||
|
@ -93,7 +93,7 @@ def view(filePath,fileName,showAll=0,showEtch=0,showEtch2=0,showEtch3=0,showDril
|
||||||
checkMinMax(gcode_minXY,gcode_maxXY)
|
checkMinMax(gcode_minXY,gcode_maxXY)
|
||||||
|
|
||||||
if showAll or showEtch2:
|
if showAll or showEtch2:
|
||||||
print "\n Loading etch (2nd pass)..."
|
print("\n Loading etch (2nd pass)...")
|
||||||
gcode_file = filePath+fileName+"_etch2pass.gcode"
|
gcode_file = filePath+fileName+"_etch2pass.gcode"
|
||||||
(etch_moves, travel_moves, gcode_minXY, gcode_maxXY) = gcp.parseGcodeRaw(gcode_file)
|
(etch_moves, travel_moves, gcode_minXY, gcode_maxXY) = gcp.parseGcodeRaw(gcode_file)
|
||||||
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
||||||
|
@ -101,7 +101,7 @@ def view(filePath,fileName,showAll=0,showEtch=0,showEtch2=0,showEtch3=0,showDril
|
||||||
checkMinMax(gcode_minXY,gcode_maxXY)
|
checkMinMax(gcode_minXY,gcode_maxXY)
|
||||||
|
|
||||||
if showAll or showEtch3:
|
if showAll or showEtch3:
|
||||||
print "\n Loading etch (3rd pass)..."
|
print("\n Loading etch (3rd pass)...")
|
||||||
gcode_file = filePath+fileName+"_etch3pass.gcode"
|
gcode_file = filePath+fileName+"_etch3pass.gcode"
|
||||||
(etch_moves, travel_moves, gcode_minXY, gcode_maxXY) = gcp.parseGcodeRaw(gcode_file)
|
(etch_moves, travel_moves, gcode_minXY, gcode_maxXY) = gcp.parseGcodeRaw(gcode_file)
|
||||||
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
||||||
|
@ -109,7 +109,7 @@ def view(filePath,fileName,showAll=0,showEtch=0,showEtch2=0,showEtch3=0,showDril
|
||||||
checkMinMax(gcode_minXY,gcode_maxXY)
|
checkMinMax(gcode_minXY,gcode_maxXY)
|
||||||
|
|
||||||
if showAll or showDrill:
|
if showAll or showDrill:
|
||||||
print "\n Loading drill..."
|
print("\n Loading drill...")
|
||||||
gcode_file = filePath+fileName+"_drill.gcode"
|
gcode_file = filePath+fileName+"_drill.gcode"
|
||||||
(etch_moves, travel_moves, gcode_minXY, gcode_maxXY) = gcp.parseGcodeRaw(gcode_file)
|
(etch_moves, travel_moves, gcode_minXY, gcode_maxXY) = gcp.parseGcodeRaw(gcode_file)
|
||||||
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
||||||
|
@ -117,7 +117,7 @@ def view(filePath,fileName,showAll=0,showEtch=0,showEtch2=0,showEtch3=0,showDril
|
||||||
checkMinMax(gcode_minXY,gcode_maxXY)
|
checkMinMax(gcode_minXY,gcode_maxXY)
|
||||||
|
|
||||||
if showAll or showEdge:
|
if showAll or showEdge:
|
||||||
print "\n Loading edge..."
|
print("\n Loading edge...")
|
||||||
gcode_file = filePath+fileName+"_edge.gcode"
|
gcode_file = filePath+fileName+"_edge.gcode"
|
||||||
(etch_moves, travel_moves, gcode_minXY, gcode_maxXY) = gcp.parseGcodeRaw(gcode_file)
|
(etch_moves, travel_moves, gcode_minXY, gcode_maxXY) = gcp.parseGcodeRaw(gcode_file)
|
||||||
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
(etch_moves, travel_moves) = gcp.optimize(etch_moves)
|
||||||
|
|
|
@ -35,7 +35,7 @@ class LINE:
|
||||||
self.inside = inside
|
self.inside = inside
|
||||||
self.delete = delete
|
self.delete = delete
|
||||||
def merge_lines(gGCODES):
|
def merge_lines(gGCODES):
|
||||||
print "merge lines ..."
|
print("merge lines ...")
|
||||||
i = 0
|
i = 0
|
||||||
while i< len(gGCODES)-1:
|
while i< len(gGCODES)-1:
|
||||||
if(gGCODES[i].gtype <= 2):
|
if(gGCODES[i].gtype <= 2):
|
||||||
|
@ -62,7 +62,7 @@ def merge_lines(gGCODES):
|
||||||
a1 = (dy1)/(dx1)
|
a1 = (dy1)/(dx1)
|
||||||
b1 = gGCODES[i].y1 - a1 * gGCODES[i].x1
|
b1 = gGCODES[i].y1 - a1 * gGCODES[i].x1
|
||||||
j = i + 1
|
j = i + 1
|
||||||
#print "i =",i,", j =",j
|
#print("i =",i,", j =",j
|
||||||
while j< len(gGCODES):
|
while j< len(gGCODES):
|
||||||
if(gGCODES[j].gtype <= 2):
|
if(gGCODES[j].gtype <= 2):
|
||||||
j += 1
|
j += 1
|
||||||
|
@ -150,19 +150,19 @@ def merge_lines(gGCODES):
|
||||||
gGCODES[i].gtype = 0
|
gGCODES[i].gtype = 0
|
||||||
break
|
break
|
||||||
elif abs(gGCODES[i].y1 - gGCODES[j].y1) <= (w2/2 + w1/2):
|
elif abs(gGCODES[i].y1 - gGCODES[j].y1) <= (w2/2 + w1/2):
|
||||||
#print w2/2 + w1/2, gGCODES[i].y1 - gGCODES[j].y1
|
#print(w2/2 + w1/2, gGCODES[i].y1 - gGCODES[j].y1
|
||||||
#
|
#
|
||||||
x2min = gGCODES[j].x1
|
x2min = gGCODES[j].x1
|
||||||
x2max = gGCODES[j].x2
|
x2max = gGCODES[j].x2
|
||||||
if(gGCODES[j].x2 < gGCODES[j].x1):
|
if(gGCODES[j].x2 < gGCODES[j].x1):
|
||||||
x2min = gGCODES[j].x2
|
x2min = gGCODES[j].x2
|
||||||
x2max = gGCODES[j].x1
|
x2max = gGCODES[j].x1
|
||||||
#print "near"
|
#print("near"
|
||||||
#if gGCODES[i].gtype == 4 and gGCODES[j].gtype == 4:
|
#if gGCODES[i].gtype == 4 and gGCODES[j].gtype == 4:
|
||||||
if abs((x1max-x1min) - (x2max-x2min)) < SMALL: #same length
|
if abs((x1max-x1min) - (x2max-x2min)) < SMALL: #same length
|
||||||
#print "same"
|
#print("same"
|
||||||
if abs((x1max+x1min)/2 - (x2max+x2min)/2) < SMALL: #same center
|
if abs((x1max+x1min)/2 - (x2max+x2min)/2) < SMALL: #same center
|
||||||
#print "center"
|
#print("center"
|
||||||
tmp_ymin = gGCODES[i].y1 - w1/2
|
tmp_ymin = gGCODES[i].y1 - w1/2
|
||||||
tmp_ymax = gGCODES[j].y1 + w2/2
|
tmp_ymax = gGCODES[j].y1 + w2/2
|
||||||
if tmp_ymin > gGCODES[j].y1 - w2/2:
|
if tmp_ymin > gGCODES[j].y1 - w2/2:
|
||||||
|
@ -345,7 +345,7 @@ def merge_lines(gGCODES):
|
||||||
return gGCODES
|
return gGCODES
|
||||||
def check_duplication(gGCODES):
|
def check_duplication(gGCODES):
|
||||||
#global gGCODES,TINY
|
#global gGCODES,TINY
|
||||||
print "Check overlapping lines ..."
|
print("Check overlapping lines ...")
|
||||||
i = 0
|
i = 0
|
||||||
|
|
||||||
while i< len(gGCODES)-1:
|
while i< len(gGCODES)-1:
|
||||||
|
@ -413,11 +413,11 @@ def check_duplication(gGCODES):
|
||||||
aj=dyj/dxj
|
aj=dyj/dxj
|
||||||
bj=yj1-aj*xj1
|
bj=yj1-aj*xj1
|
||||||
if(abs(aj-ai) < TINY and abs(bj-bi) < TINY):
|
if(abs(aj-ai) < TINY and abs(bj-bi) < TINY):
|
||||||
#print "a=" + str(ai)
|
#print("a=" + str(ai)
|
||||||
if(xj_min>=xi_min):
|
if(xj_min>=xi_min):
|
||||||
#print "a"
|
#print("a"
|
||||||
if(xj_max<=xi_max):
|
if(xj_max<=xi_max):
|
||||||
#print "aa"
|
#print("aa"
|
||||||
#overlap
|
#overlap
|
||||||
if(gGCODES[i].mod1 >= gGCODES[j].mod1):
|
if(gGCODES[i].mod1 >= gGCODES[j].mod1):
|
||||||
gGCODES[j].gtype=0
|
gGCODES[j].gtype=0
|
||||||
|
@ -425,7 +425,7 @@ def check_duplication(gGCODES):
|
||||||
continue
|
continue
|
||||||
elif(xi_max >= xj_min): # xj_max > xi_max
|
elif(xi_max >= xj_min): # xj_max > xi_max
|
||||||
if(gGCODES[i].mod1 == gGCODES[j].mod1):
|
if(gGCODES[i].mod1 == gGCODES[j].mod1):
|
||||||
#print "ab i=" +str(i) + ", j=" + str(j)
|
#print("ab i=" +str(i) + ", j=" + str(j)
|
||||||
gGCODES[j].gtype=0
|
gGCODES[j].gtype=0
|
||||||
#gGCODES[i].x1 = xi_min
|
#gGCODES[i].x1 = xi_min
|
||||||
#gGCODES[i].y1 = gGCODES[i].y1
|
#gGCODES[i].y1 = gGCODES[i].y1
|
||||||
|
@ -440,18 +440,18 @@ def check_duplication(gGCODES):
|
||||||
#j += 1
|
#j += 1
|
||||||
#continue
|
#continue
|
||||||
elif(xj_min<=xi_min):
|
elif(xj_min<=xi_min):
|
||||||
#print "b"
|
#print("b"
|
||||||
if(xj_max>=xi_max):
|
if(xj_max>=xi_max):
|
||||||
#print "ba"
|
#print("ba"
|
||||||
#overlap
|
#overlap
|
||||||
if(gGCODES[i].mod1 <= gGCODES[j].mod1):
|
if(gGCODES[i].mod1 <= gGCODES[j].mod1):
|
||||||
gGCODES[i].gtype=0
|
gGCODES[i].gtype=0
|
||||||
break
|
break
|
||||||
elif(xj_max >= xi_min): # xj_max < xi_max
|
elif(xj_max >= xi_min): # xj_max < xi_max
|
||||||
if(gGCODES[i].mod1 == gGCODES[j].mod1):
|
if(gGCODES[i].mod1 == gGCODES[j].mod1):
|
||||||
#print "bb i=" +str(i) + ", j=" + str(j)
|
#print("bb i=" +str(i) + ", j=" + str(j)
|
||||||
gGCODES[j].gtype=0
|
gGCODES[j].gtype=0
|
||||||
#print "x1=" +str(gGCODES[i].x1) +", y1=" +str(gGCODES[i].y1) +", x2=" +str(gGCODES[i].x2) +", y2=" +str(gGCODES[i].y2)
|
#print("x1=" +str(gGCODES[i].x1) +", y1=" +str(gGCODES[i].y1) +", x2=" +str(gGCODES[i].x2) +", y2=" +str(gGCODES[i].y2)
|
||||||
#gGCODES[i].x2 = xi_max
|
#gGCODES[i].x2 = xi_max
|
||||||
#gGCODES[i].y2 = gGCODES[i].y2
|
#gGCODES[i].y2 = gGCODES[i].y2
|
||||||
#if(m_x1_flag): #if xi_max = gGCODES[i].x1
|
#if(m_x1_flag): #if xi_max = gGCODES[i].x1
|
||||||
|
@ -465,7 +465,7 @@ def check_duplication(gGCODES):
|
||||||
if(xj1>xj2): #if xi_min = xj2
|
if(xj1>xj2): #if xi_min = xj2
|
||||||
gGCODES[i].y1 = gGCODES[j].y2
|
gGCODES[i].y1 = gGCODES[j].y2
|
||||||
xi_min = xj_min
|
xi_min = xj_min
|
||||||
#print "x1=" +str(gGCODES[i].x1) +", y1=" +str(gGCODES[i].y1) +", x2=" +str(gGCODES[i].x2) +", y2=" +str(gGCODES[i].y2)
|
#print("x1=" +str(gGCODES[i].x1) +", y1=" +str(gGCODES[i].y1) +", x2=" +str(gGCODES[i].x2) +", y2=" +str(gGCODES[i].y2)
|
||||||
#j += 1
|
#j += 1
|
||||||
#continue
|
#continue
|
||||||
else: #dxi==0
|
else: #dxi==0
|
||||||
|
@ -512,11 +512,11 @@ def check_duplication(gGCODES):
|
||||||
else: #ti != tj
|
else: #ti != tj
|
||||||
if(ti == 2):
|
if(ti == 2):
|
||||||
if(tj == 3 or tj == 4):
|
if(tj == 3 or tj == 4):
|
||||||
#print "rect ti"
|
#print("rect ti"
|
||||||
if(gGCODES[j].x1 == gGCODES[j].x2 and gGCODES[i].x1 == gGCODES[j].x1): #Vertical
|
if(gGCODES[j].x1 == gGCODES[j].x2 and gGCODES[i].x1 == gGCODES[j].x1): #Vertical
|
||||||
#print "ti check x"
|
#print("ti check x"
|
||||||
if(gGCODES[i].mod1 == gGCODES[j].mod1):
|
if(gGCODES[i].mod1 == gGCODES[j].mod1):
|
||||||
#print "ti check x mod1"
|
#print("ti check x mod1"
|
||||||
#line = [gGCODES[i].x1,gGCODES[i].y1-gGCODES[i].mod2/2,gGCODES[i].x1,gGCODES[i].y1+gGCODES[i].mod2/2]
|
#line = [gGCODES[i].x1,gGCODES[i].y1-gGCODES[i].mod2/2,gGCODES[i].x1,gGCODES[i].y1+gGCODES[i].mod2/2]
|
||||||
x1=gGCODES[i].x1
|
x1=gGCODES[i].x1
|
||||||
y1=gGCODES[i].y1-gGCODES[i].mod2/2
|
y1=gGCODES[i].y1-gGCODES[i].mod2/2
|
||||||
|
@ -532,11 +532,11 @@ def check_duplication(gGCODES):
|
||||||
gGCODES[j].gtype=0
|
gGCODES[j].gtype=0
|
||||||
if(ovflag == 3):
|
if(ovflag == 3):
|
||||||
gGCODES[i].gtype=0
|
gGCODES[i].gtype=0
|
||||||
print "ti overlap =" + str(ovflag)
|
print("ti overlap =" + str(ovflag))
|
||||||
#print line_joint(x1,y1,x2,y2,xa,ya,xb,yb,ovflag)
|
#print(line_joint(x1,y1,x2,y2,xa,ya,xb,yb,ovflag)
|
||||||
tx1,ty1,tx2,ty2=line_joint(x1,y1,x2,y2,xa,ya,xb,yb,ovflag)
|
tx1,ty1,tx2,ty2=line_joint(x1,y1,x2,y2,xa,ya,xb,yb,ovflag)
|
||||||
if(tj == 4): #Rect
|
if(tj == 4): #Rect
|
||||||
print "Rect-Rect"
|
print("Rect-Rect")
|
||||||
gGCODES[j].gtype = 0
|
gGCODES[j].gtype = 0
|
||||||
gGCODES[i].gtype = 4
|
gGCODES[i].gtype = 4
|
||||||
gGCODES[i].x1 = tx1
|
gGCODES[i].x1 = tx1
|
||||||
|
@ -544,7 +544,7 @@ def check_duplication(gGCODES):
|
||||||
gGCODES[i].x2 = tx2
|
gGCODES[i].x2 = tx2
|
||||||
gGCODES[i].y2 = ty2
|
gGCODES[i].y2 = ty2
|
||||||
elif(tj == 3):
|
elif(tj == 3):
|
||||||
print "rect-cir"
|
print("rect-cir")
|
||||||
gGCODES[j].gtype = 0
|
gGCODES[j].gtype = 0
|
||||||
gGCODES[i].gtype = 5
|
gGCODES[i].gtype = 5
|
||||||
gGCODES[i].mod1 =gGCODES[j].mod1
|
gGCODES[i].mod1 =gGCODES[j].mod1
|
||||||
|
@ -558,9 +558,9 @@ def check_duplication(gGCODES):
|
||||||
gGCODES[i].x2 = tx1
|
gGCODES[i].x2 = tx1
|
||||||
gGCODES[i].y2 = ty1
|
gGCODES[i].y2 = ty1
|
||||||
if(gGCODES[j].y1 == gGCODES[j].y2 and gGCODES[i].y1 == gGCODES[j].y1): #Horizontal
|
if(gGCODES[j].y1 == gGCODES[j].y2 and gGCODES[i].y1 == gGCODES[j].y1): #Horizontal
|
||||||
#print "ti check y"
|
#print("ti check y"
|
||||||
if(gGCODES[i].mod2 == gGCODES[j].mod1):
|
if(gGCODES[i].mod2 == gGCODES[j].mod1):
|
||||||
#print "ti check y mod1"
|
#print("ti check y mod1"
|
||||||
#line = [gGCODES[i].x1-gGCODES[i].mod1/2,gGCODES[i].y1,gGCODES[i].x1+gGCODES[i].mod1/2,gGCODES[i].y1]
|
#line = [gGCODES[i].x1-gGCODES[i].mod1/2,gGCODES[i].y1,gGCODES[i].x1+gGCODES[i].mod1/2,gGCODES[i].y1]
|
||||||
x1=gGCODES[i].x1-gGCODES[i].mod1/2
|
x1=gGCODES[i].x1-gGCODES[i].mod1/2
|
||||||
y1=gGCODES[i].y1
|
y1=gGCODES[i].y1
|
||||||
|
@ -576,11 +576,11 @@ def check_duplication(gGCODES):
|
||||||
gGCODES[j].gtype=0
|
gGCODES[j].gtype=0
|
||||||
if(ovflag == 7):
|
if(ovflag == 7):
|
||||||
gGCODES[i].gtype=0
|
gGCODES[i].gtype=0
|
||||||
print "ti overlap =" + str(ovflag)
|
print("ti overlap =" + str(ovflag))
|
||||||
tx1,ty1,tx2,ty2=line_joint(x1,y1,x2,y2,xa,ya,xb,yb,ovflag)
|
tx1,ty1,tx2,ty2=line_joint(x1,y1,x2,y2,xa,ya,xb,yb,ovflag)
|
||||||
|
|
||||||
if(tj == 4): #Rect
|
if(tj == 4): #Rect
|
||||||
print "Rect-Rect"
|
print("Rect-Rect")
|
||||||
gGCODES[j].gtype = 0
|
gGCODES[j].gtype = 0
|
||||||
gGCODES[i].gtype = 4
|
gGCODES[i].gtype = 4
|
||||||
gGCODES[i].x1 = tx1
|
gGCODES[i].x1 = tx1
|
||||||
|
@ -588,7 +588,7 @@ def check_duplication(gGCODES):
|
||||||
gGCODES[i].x2 = tx2
|
gGCODES[i].x2 = tx2
|
||||||
gGCODES[i].y2 = ty2
|
gGCODES[i].y2 = ty2
|
||||||
elif(tj == 3):
|
elif(tj == 3):
|
||||||
print "rect-cir"
|
print("rect-cir")
|
||||||
gGCODES[j].gtype = 0
|
gGCODES[j].gtype = 0
|
||||||
gGCODES[i].gtype = 5
|
gGCODES[i].gtype = 5
|
||||||
gGCODES[i].mod1 =gGCODES[j].mod1
|
gGCODES[i].mod1 =gGCODES[j].mod1
|
||||||
|
@ -603,11 +603,11 @@ def check_duplication(gGCODES):
|
||||||
gGCODES[i].y2 = ty1
|
gGCODES[i].y2 = ty1
|
||||||
if(tj == 2):
|
if(tj == 2):
|
||||||
if(ti == 3 or ti == 4):
|
if(ti == 3 or ti == 4):
|
||||||
#print "rect tj"
|
#print("rect tj"
|
||||||
if(gGCODES[i].x1 == gGCODES[i].x2 and gGCODES[i].x1 == gGCODES[j].x1): #Vertical
|
if(gGCODES[i].x1 == gGCODES[i].x2 and gGCODES[i].x1 == gGCODES[j].x1): #Vertical
|
||||||
#print "ti check x"
|
#print("ti check x"
|
||||||
if(gGCODES[i].mod1 == gGCODES[j].mod1):
|
if(gGCODES[i].mod1 == gGCODES[j].mod1):
|
||||||
#print "ti check x mod1"
|
#print("ti check x mod1"
|
||||||
#line = [gGCODES[i].x1,gGCODES[i].y1-gGCODES[i].mod2/2,gGCODES[i].x1,gGCODES[i].y1+gGCODES[i].mod2/2]
|
#line = [gGCODES[i].x1,gGCODES[i].y1-gGCODES[i].mod2/2,gGCODES[i].x1,gGCODES[i].y1+gGCODES[i].mod2/2]
|
||||||
x1=gGCODES[j].x1
|
x1=gGCODES[j].x1
|
||||||
y1=gGCODES[j].y1-gGCODES[j].mod2/2
|
y1=gGCODES[j].y1-gGCODES[j].mod2/2
|
||||||
|
@ -623,11 +623,11 @@ def check_duplication(gGCODES):
|
||||||
gGCODES[j].gtype=0
|
gGCODES[j].gtype=0
|
||||||
if(ovflag == 3):
|
if(ovflag == 3):
|
||||||
gGCODES[i].gtype=0
|
gGCODES[i].gtype=0
|
||||||
print "tj overlap =" + str(ovflag)
|
print("tj overlap =" + str(ovflag))
|
||||||
#print line_joint(x1,y1,x2,y2,xa,ya,xb,yb,ovflag)
|
#print(line_joint(x1,y1,x2,y2,xa,ya,xb,yb,ovflag)
|
||||||
tx1,ty1,tx2,ty2=line_joint(x1,y1,x2,y2,xa,ya,xb,yb,ovflag)
|
tx1,ty1,tx2,ty2=line_joint(x1,y1,x2,y2,xa,ya,xb,yb,ovflag)
|
||||||
if(tj == 4): #Rect
|
if(tj == 4): #Rect
|
||||||
print "Rect-Rect"
|
print("Rect-Rect")
|
||||||
gGCODES[j].gtype = 0
|
gGCODES[j].gtype = 0
|
||||||
gGCODES[i].gtype = 4
|
gGCODES[i].gtype = 4
|
||||||
gGCODES[i].x1 = tx1
|
gGCODES[i].x1 = tx1
|
||||||
|
@ -635,7 +635,7 @@ def check_duplication(gGCODES):
|
||||||
gGCODES[i].x2 = tx2
|
gGCODES[i].x2 = tx2
|
||||||
gGCODES[i].y2 = ty2
|
gGCODES[i].y2 = ty2
|
||||||
elif(tj == 3):
|
elif(tj == 3):
|
||||||
print "rect-cir"
|
print("rect-cir")
|
||||||
gGCODES[j].gtype = 0
|
gGCODES[j].gtype = 0
|
||||||
gGCODES[i].gtype = 5
|
gGCODES[i].gtype = 5
|
||||||
gGCODES[i].mod1 =gGCODES[j].mod1
|
gGCODES[i].mod1 =gGCODES[j].mod1
|
||||||
|
@ -649,7 +649,7 @@ def check_duplication(gGCODES):
|
||||||
gGCODES[i].x2 = tx1
|
gGCODES[i].x2 = tx1
|
||||||
gGCODES[i].y2 = ty1
|
gGCODES[i].y2 = ty1
|
||||||
if(gGCODES[i].y1 == gGCODES[i].y2 and gGCODES[i].y1 == gGCODES[j].y1): #Horizontal
|
if(gGCODES[i].y1 == gGCODES[i].y2 and gGCODES[i].y1 == gGCODES[j].y1): #Horizontal
|
||||||
#print "ti check y"
|
#print("ti check y"
|
||||||
if(gGCODES[i].mod1 == gGCODES[j].mod2):
|
if(gGCODES[i].mod1 == gGCODES[j].mod2):
|
||||||
|
|
||||||
x1=gGCODES[j].x1-gGCODES[j].mod1/2
|
x1=gGCODES[j].x1-gGCODES[j].mod1/2
|
||||||
|
@ -666,11 +666,11 @@ def check_duplication(gGCODES):
|
||||||
gGCODES[j].gtype=0
|
gGCODES[j].gtype=0
|
||||||
if(ovflag == 7):
|
if(ovflag == 7):
|
||||||
gGCODES[i].gtype=0
|
gGCODES[i].gtype=0
|
||||||
print "tj overlap =" + str(ovflag)
|
print("tj overlap =" + str(ovflag))
|
||||||
tx1,ty1,tx2,ty2=line_joint(x1,y1,x2,y2,xa,ya,xb,yb,ovflag)
|
tx1,ty1,tx2,ty2=line_joint(x1,y1,x2,y2,xa,ya,xb,yb,ovflag)
|
||||||
|
|
||||||
if(tj == 4): #Rect
|
if(tj == 4): #Rect
|
||||||
print "Rect-Rect"
|
print("Rect-Rect")
|
||||||
gGCODES[j].gtype = 0
|
gGCODES[j].gtype = 0
|
||||||
gGCODES[i].gtype = 4
|
gGCODES[i].gtype = 4
|
||||||
gGCODES[i].x1 = tx1
|
gGCODES[i].x1 = tx1
|
||||||
|
@ -678,7 +678,7 @@ def check_duplication(gGCODES):
|
||||||
gGCODES[i].x2 = tx2
|
gGCODES[i].x2 = tx2
|
||||||
gGCODES[i].y2 = ty2
|
gGCODES[i].y2 = ty2
|
||||||
elif(tj == 3):
|
elif(tj == 3):
|
||||||
print "rect-cir"
|
print("rect-cir")
|
||||||
gGCODES[j].gtype = 0
|
gGCODES[j].gtype = 0
|
||||||
gGCODES[i].gtype = 5
|
gGCODES[i].gtype = 5
|
||||||
gGCODES[i].mod1 =gGCODES[j].mod1
|
gGCODES[i].mod1 =gGCODES[j].mod1
|
||||||
|
@ -826,7 +826,7 @@ def merge(gPOLYGONS, LINE, gLINES,gLINES2):
|
||||||
#del all polygons
|
#del all polygons
|
||||||
poly3.delete = 1
|
poly3.delete = 1
|
||||||
gPOLYGONS = line_merge(gPOLYGONS, gLINES)
|
gPOLYGONS = line_merge(gPOLYGONS, gLINES)
|
||||||
print "End merge polygons"
|
print("End merge polygons")
|
||||||
return gPOLYGONS
|
return gPOLYGONS
|
||||||
|
|
||||||
def line_merge(gPOLYGONS, gLINES):
|
def line_merge(gPOLYGONS, gLINES):
|
||||||
|
@ -853,7 +853,7 @@ def line_merge(gPOLYGONS, gLINES):
|
||||||
|
|
||||||
def merge_polygons(gPOLYGONS):
|
def merge_polygons(gPOLYGONS):
|
||||||
#global gPOLYGONS
|
#global gPOLYGONS
|
||||||
print " Start merge lines 2"
|
print(" Start merge lines 2")
|
||||||
for poly1 in gPOLYGONS:
|
for poly1 in gPOLYGONS:
|
||||||
if(poly1.delete):
|
if(poly1.delete):
|
||||||
continue
|
continue
|
||||||
|
@ -878,7 +878,7 @@ def merge_polygons(gPOLYGONS):
|
||||||
|
|
||||||
def IsLineOverlap(x1,y1,x2,y2,xa,ya,xb,yb):
|
def IsLineOverlap(x1,y1,x2,y2,xa,ya,xb,yb):
|
||||||
global TINY
|
global TINY
|
||||||
#print "check overlap"
|
#print("check overlap"
|
||||||
dx1 = x2-x1
|
dx1 = x2-x1
|
||||||
#dy1 = y2-y1
|
#dy1 = y2-y1
|
||||||
dx2 = xb-xa
|
dx2 = xb-xa
|
||||||
|
@ -900,9 +900,9 @@ def IsLineOverlap(x1,y1,x2,y2,xa,ya,xb,yb):
|
||||||
if(abs(a1-a2) < TINY):
|
if(abs(a1-a2) < TINY):
|
||||||
b1 = y1-a1*x1
|
b1 = y1-a1*x1
|
||||||
b2 = ya-a2*xa
|
b2 = ya-a2*xa
|
||||||
#print "same angle " + str(a1 )+ ", b1=" + str(b1)+ ", b2=" + str(b2) + ", b2-b1=" + str(abs(b2-b1)) +", y1=" +str(y1) + ", ya=" + str(ya)
|
#print("same angle " + str(a1 )+ ", b1=" + str(b1)+ ", b2=" + str(b2) + ", b2-b1=" + str(abs(b2-b1)) +", y1=" +str(y1) + ", ya=" + str(ya)
|
||||||
if(abs(b2-b1) < TINY): #Horizontal
|
if(abs(b2-b1) < TINY): #Horizontal
|
||||||
#print "same b " + str(b1)
|
#print("same b " + str(b1)
|
||||||
if (xa - x1)*(xa - x2) <= 0 or (xb - x1)*(xb - x2):
|
if (xa - x1)*(xa - x2) <= 0 or (xb - x1)*(xb - x2):
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
@ -946,7 +946,7 @@ def CrossAndIn(line_id,spoints, gLINES, LINE):
|
||||||
#global gLINES, gCCOUNT1, gCCOUNT2,TEST_POINTS1,TEST_POINTS2
|
#global gLINES, gCCOUNT1, gCCOUNT2,TEST_POINTS1,TEST_POINTS2
|
||||||
global gCCOUNT1, gCCOUNT2,TEST_POINTS1,TEST_POINTS2
|
global gCCOUNT1, gCCOUNT2,TEST_POINTS1,TEST_POINTS2
|
||||||
#check in or out
|
#check in or out
|
||||||
#print line_id
|
#print(line_id
|
||||||
if(gLINES[line_id].inside):
|
if(gLINES[line_id].inside):
|
||||||
return 0
|
return 0
|
||||||
xa = gLINES[line_id].x1
|
xa = gLINES[line_id].x1
|
||||||
|
@ -973,7 +973,7 @@ def CrossAndIn(line_id,spoints, gLINES, LINE):
|
||||||
(cross_flag,cross_x,cross_y)=find_cross_point(xa,ya,xb,yb,xp1,yp1,xp2,yp2)
|
(cross_flag,cross_x,cross_y)=find_cross_point(xa,ya,xb,yb,xp1,yp1,xp2,yp2)
|
||||||
cross_num+=cross_flag
|
cross_num+=cross_flag
|
||||||
if(cross_flag):
|
if(cross_flag):
|
||||||
#print "cross"
|
#print("cross"
|
||||||
cross_points.extend([cross_x,cross_y])
|
cross_points.extend([cross_x,cross_y])
|
||||||
cross_nums.append(si)
|
cross_nums.append(si)
|
||||||
|
|
||||||
|
@ -1029,9 +1029,9 @@ def CrossAndIn(line_id,spoints, gLINES, LINE):
|
||||||
|
|
||||||
if(cross_num>1):
|
if(cross_num>1):
|
||||||
cross_points = sort_points_by_dist(xa,ya,cross_points)
|
cross_points = sort_points_by_dist(xa,ya,cross_points)
|
||||||
#print calc_dist(gLINES[line_id].x1,gLINES[line_id].y1,cross_points[0],cross_points[1])
|
#print(calc_dist(gLINES[line_id].x1,gLINES[line_id].y1,cross_points[0],cross_points[1])
|
||||||
if(calc_dist(gLINES[line_id].x1,gLINES[line_id].y1,cross_points[0],cross_points[1])<=0.0):
|
if(calc_dist(gLINES[line_id].x1,gLINES[line_id].y1,cross_points[0],cross_points[1])<=0.0):
|
||||||
#print "the cross point is same as p1 in_flag1=" + str(in_flag1) + "in_flag2=" + str(in_flag2)
|
#print("the cross point is same as p1 in_flag1=" + str(in_flag1) + "in_flag2=" + str(in_flag2)
|
||||||
if(in_flag1 != in_flag2):
|
if(in_flag1 != in_flag2):
|
||||||
gLINES[line_id].inside = 1
|
gLINES[line_id].inside = 1
|
||||||
else:
|
else:
|
||||||
|
@ -1065,7 +1065,7 @@ def CrossAndIn(line_id,spoints, gLINES, LINE):
|
||||||
if(in_flag1 == in_flag2):
|
if(in_flag1 == in_flag2):
|
||||||
#in in
|
#in in
|
||||||
gLINES[line_id].inside=in_flag1
|
gLINES[line_id].inside=in_flag1
|
||||||
#print "in-in or Out-OUT:flag="+str(in_flag1)+ ", id=" +str(line_id)
|
#print("in-in or Out-OUT:flag="+str(in_flag1)+ ", id=" +str(line_id)
|
||||||
else:
|
else:
|
||||||
#in out
|
#in out
|
||||||
if(ovflag <=0):
|
if(ovflag <=0):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
(Generated by ./pygerber2gcode_cui_MOD.py )
|
(Generated by ./pygerber2gcode_cui_MOD.py )
|
||||||
( 2013-07-28 02:00:01 )
|
( 2013-07-28 13:51:51 )
|
||||||
(Initialize)
|
(Initialize)
|
||||||
|
|
||||||
(Start form here)
|
(Start form here)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
(Generated by ./pygerber2gcode_cui_MOD.py )
|
(Generated by ./pygerber2gcode_cui_MOD.py )
|
||||||
( 2013-07-28 02:00:01 )
|
( 2013-07-28 13:51:51 )
|
||||||
(Initialize)
|
(Initialize)
|
||||||
|
|
||||||
(Start form here)
|
(Start form here)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
(Generated by ./pygerber2gcode_cui_MOD.py )
|
(Generated by ./pygerber2gcode_cui_MOD.py )
|
||||||
( 2013-07-28 02:00:01 )
|
( 2013-07-28 13:51:51 )
|
||||||
(Initialize)
|
(Initialize)
|
||||||
|
|
||||||
(Start form here)
|
(Start form here)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
(Generated by ./pygerber2gcode_cui_MOD.py )
|
(Generated by ./pygerber2gcode_cui_MOD.py )
|
||||||
( 2013-07-28 02:00:01 )
|
( 2013-07-28 13:51:51 )
|
||||||
(Initialize)
|
(Initialize)
|
||||||
|
|
||||||
(Start form here)
|
(Start form here)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
(Generated by ./pygerber2gcode_cui_MOD.py )
|
(Generated by ./pygerber2gcode_cui_MOD.py )
|
||||||
( 2013-07-28 02:00:01 )
|
( 2013-07-28 13:51:51 )
|
||||||
(Initialize)
|
(Initialize)
|
||||||
|
|
||||||
(Start form here)
|
(Start form here)
|
||||||
|
|
|
@ -246,54 +246,54 @@ def main():
|
||||||
front_poly_3pass = []
|
front_poly_3pass = []
|
||||||
back_poly_3pass = []
|
back_poly_3pass = []
|
||||||
if FRONT_FILE:
|
if FRONT_FILE:
|
||||||
#print "Front file =",FRONT_FILE
|
#print("Front file =",FRONT_FILE
|
||||||
front_gerber = read_Gerber(GERBER_DIR,FRONT_FILE)
|
front_gerber = read_Gerber(GERBER_DIR,FRONT_FILE)
|
||||||
#front_gerber = gm.merge_lines(front_gerber)
|
#front_gerber = gm.merge_lines(front_gerber)
|
||||||
front_gerber = gm.check_duplication(front_gerber)
|
front_gerber = gm.check_duplication(front_gerber)
|
||||||
#print len(front_gerber)
|
#print(len(front_gerber)
|
||||||
front_poly = gerber2polygon(front_gerber)
|
front_poly = gerber2polygon(front_gerber)
|
||||||
#print len(front_poly)
|
#print(len(front_poly)
|
||||||
front_poly = gm.merge(front_poly, LINE, gLINES,gLINES2)
|
front_poly = gm.merge(front_poly, LINE, gLINES,gLINES2)
|
||||||
if abs(float(ROT_ANG)) > TINY:
|
if abs(float(ROT_ANG)) > TINY:
|
||||||
front_poly = rot_poly(front_poly)
|
front_poly = rot_poly(front_poly)
|
||||||
if MIRROR_FRONT:
|
if MIRROR_FRONT:
|
||||||
front_poly = mirror_poly(front_poly)
|
front_poly = mirror_poly(front_poly)
|
||||||
print len(front_poly)
|
print(len(front_poly))
|
||||||
if TOOL_2PASS_D > 0:
|
if TOOL_2PASS_D > 0:
|
||||||
print "Processing 2nd pass..."
|
print("Processing 2nd pass...")
|
||||||
PREV_TOOL_D = TOOL_D
|
PREV_TOOL_D = TOOL_D
|
||||||
TOOL_D = TOOL_2PASS_D # Set the thicker tool
|
TOOL_D = TOOL_2PASS_D # Set the thicker tool
|
||||||
#print "Front file =",FRONT_FILE
|
#print("Front file =",FRONT_FILE
|
||||||
front_gerber_2pass = read_Gerber(GERBER_DIR,FRONT_FILE)
|
front_gerber_2pass = read_Gerber(GERBER_DIR,FRONT_FILE)
|
||||||
#front_gerber = gm.merge_lines(front_gerber)
|
#front_gerber = gm.merge_lines(front_gerber)
|
||||||
front_gerber_2pass = gm.check_duplication(front_gerber_2pass)
|
front_gerber_2pass = gm.check_duplication(front_gerber_2pass)
|
||||||
#print len(front_gerber)
|
#print(len(front_gerber)
|
||||||
front_poly_2pass = gerber2polygon(front_gerber_2pass)
|
front_poly_2pass = gerber2polygon(front_gerber_2pass)
|
||||||
#print len(front_poly)
|
#print(len(front_poly)
|
||||||
front_poly_2pass = gm.merge(front_poly_2pass, LINE, gLINES,gLINES2)
|
front_poly_2pass = gm.merge(front_poly_2pass, LINE, gLINES,gLINES2)
|
||||||
if abs(float(ROT_ANG)) > TINY:
|
if abs(float(ROT_ANG)) > TINY:
|
||||||
front_poly_2pass = rot_poly(front_poly_2pass)
|
front_poly_2pass = rot_poly(front_poly_2pass)
|
||||||
if MIRROR_FRONT:
|
if MIRROR_FRONT:
|
||||||
front_poly_2pass = mirror_poly(front_poly_2pass)
|
front_poly_2pass = mirror_poly(front_poly_2pass)
|
||||||
print len(front_poly_2pass)
|
print(len(front_poly_2pass))
|
||||||
TOOL_D = PREV_TOOL_D
|
TOOL_D = PREV_TOOL_D
|
||||||
if TOOL_3PASS_D > 0:
|
if TOOL_3PASS_D > 0:
|
||||||
print "Processing 3nd pass..."
|
print("Processing 3nd pass...")
|
||||||
PREV_TOOL_D = TOOL_D
|
PREV_TOOL_D = TOOL_D
|
||||||
TOOL_D = TOOL_3PASS_D # Set the thicker tool
|
TOOL_D = TOOL_3PASS_D # Set the thicker tool
|
||||||
#print "Front file =",FRONT_FILE
|
#print("Front file =",FRONT_FILE
|
||||||
front_gerber_3pass = read_Gerber(GERBER_DIR,FRONT_FILE)
|
front_gerber_3pass = read_Gerber(GERBER_DIR,FRONT_FILE)
|
||||||
#front_gerber = gm.merge_lines(front_gerber)
|
#front_gerber = gm.merge_lines(front_gerber)
|
||||||
front_gerber_3pass = gm.check_duplication(front_gerber_3pass)
|
front_gerber_3pass = gm.check_duplication(front_gerber_3pass)
|
||||||
#print len(front_gerber)
|
#print(len(front_gerber)
|
||||||
front_poly_3pass = gerber2polygon(front_gerber_3pass)
|
front_poly_3pass = gerber2polygon(front_gerber_3pass)
|
||||||
#print len(front_poly)
|
#print(len(front_poly)
|
||||||
front_poly_3pass = gm.merge(front_poly_3pass, LINE, gLINES,gLINES2)
|
front_poly_3pass = gm.merge(front_poly_3pass, LINE, gLINES,gLINES2)
|
||||||
if abs(float(ROT_ANG)) > TINY:
|
if abs(float(ROT_ANG)) > TINY:
|
||||||
front_poly_3pass = rot_poly(front_poly_3pass)
|
front_poly_3pass = rot_poly(front_poly_3pass)
|
||||||
if MIRROR_FRONT:
|
if MIRROR_FRONT:
|
||||||
front_poly_3pass = mirror_poly(front_poly_3pass)
|
front_poly_3pass = mirror_poly(front_poly_3pass)
|
||||||
print len(front_poly_3pass)
|
print(len(front_poly_3pass))
|
||||||
TOOL_D = PREV_TOOL_D
|
TOOL_D = PREV_TOOL_D
|
||||||
if BACK_FILE:
|
if BACK_FILE:
|
||||||
back_gerber = read_Gerber(GERBER_DIR,BACK_FILE)
|
back_gerber = read_Gerber(GERBER_DIR,BACK_FILE)
|
||||||
|
@ -305,9 +305,9 @@ def main():
|
||||||
back_poly = rot_poly(back_poly)
|
back_poly = rot_poly(back_poly)
|
||||||
if MIRROR_BACK:
|
if MIRROR_BACK:
|
||||||
back_poly = mirror_poly(back_poly)
|
back_poly = mirror_poly(back_poly)
|
||||||
print len(back_poly)
|
print(len(back_poly))
|
||||||
if TOOL_2PASS_D > 0:
|
if TOOL_2PASS_D > 0:
|
||||||
print "Processing 2nd pass..."
|
print("Processing 2nd pass...")
|
||||||
PREV_TOOL_D = TOOL_D
|
PREV_TOOL_D = TOOL_D
|
||||||
TOOL_D = TOOL_2PASS_D # Set the thicker tool
|
TOOL_D = TOOL_2PASS_D # Set the thicker tool
|
||||||
back_gerber_2pass = read_Gerber(GERBER_DIR,BACK_FILE)
|
back_gerber_2pass = read_Gerber(GERBER_DIR,BACK_FILE)
|
||||||
|
@ -319,10 +319,10 @@ def main():
|
||||||
back_poly_2pass = rot_poly(back_poly_2pass)
|
back_poly_2pass = rot_poly(back_poly_2pass)
|
||||||
if MIRROR_BACK:
|
if MIRROR_BACK:
|
||||||
back_poly_2pass = mirror_poly(back_poly_2pass)
|
back_poly_2pass = mirror_poly(back_poly_2pass)
|
||||||
print len(back_poly_2pass)
|
print(len(back_poly_2pass))
|
||||||
TOOL_D = PREV_TOOL_D
|
TOOL_D = PREV_TOOL_D
|
||||||
if TOOL_3PASS_D > 0:
|
if TOOL_3PASS_D > 0:
|
||||||
print "Processing 3nd pass..."
|
print("Processing 3nd pass...")
|
||||||
PREV_TOOL_D = TOOL_D
|
PREV_TOOL_D = TOOL_D
|
||||||
TOOL_D = TOOL_3PASS_D # Set the thicker tool
|
TOOL_D = TOOL_3PASS_D # Set the thicker tool
|
||||||
back_gerber_3pass = read_Gerber(GERBER_DIR,BACK_FILE)
|
back_gerber_3pass = read_Gerber(GERBER_DIR,BACK_FILE)
|
||||||
|
@ -334,7 +334,7 @@ def main():
|
||||||
back_poly_3pass = rot_poly(back_poly_3pass)
|
back_poly_3pass = rot_poly(back_poly_3pass)
|
||||||
if MIRROR_BACK:
|
if MIRROR_BACK:
|
||||||
back_poly_3pass = mirror_poly(back_poly_3pass)
|
back_poly_3pass = mirror_poly(back_poly_3pass)
|
||||||
print len(back_poly_3pass)
|
print(len(back_poly_3pass))
|
||||||
TOOL_D = PREV_TOOL_D
|
TOOL_D = PREV_TOOL_D
|
||||||
if DRILL_FILE:
|
if DRILL_FILE:
|
||||||
read_Drill_file(GERBER_DIR,DRILL_FILE)
|
read_Drill_file(GERBER_DIR,DRILL_FILE)
|
||||||
|
@ -353,22 +353,18 @@ def read_config(config_file):
|
||||||
global INI_X, INI_Y, INI_Z, MOVE_HEIGHT, OUT_INCH_FLAG, IN_INCH_FLAG, MCODE_FLAG, XY_SPEED, Z_SPEED, LEFT_X, LOWER_Y, DRILL_SPEED, DRILL_DEPTH, CUT_DEPTH, TOOL_D, TOOL_2PASS_D, TOOL_3PASS_D, DRILL_D, CAD_UNIT, EDGE_TOOL_D, EDGE_DEPTH, EDGE_SPEED, EDGE_Z_SPEED, MERGE_DRILL_DATA, Z_STEP_DRILL, Z_STEP_EDGE, GERBER_COLOR, DRILL_COLOR, EDGE_COLOR , CONTOUR_COLOR, GERBER_EXT, DRILL_EXT, EDGE_EXT, GCODE_EXT, GDRILL_EXT, GEDGE_EXT, DRILL_UNIT, EDGE_UNIT, CUT_FLAG, CUT_OV
|
global INI_X, INI_Y, INI_Z, MOVE_HEIGHT, OUT_INCH_FLAG, IN_INCH_FLAG, MCODE_FLAG, XY_SPEED, Z_SPEED, LEFT_X, LOWER_Y, DRILL_SPEED, DRILL_DEPTH, CUT_DEPTH, TOOL_D, TOOL_2PASS_D, TOOL_3PASS_D, DRILL_D, CAD_UNIT, EDGE_TOOL_D, EDGE_DEPTH, EDGE_SPEED, EDGE_Z_SPEED, MERGE_DRILL_DATA, Z_STEP_DRILL, Z_STEP_EDGE, GERBER_COLOR, DRILL_COLOR, EDGE_COLOR , CONTOUR_COLOR, GERBER_EXT, DRILL_EXT, EDGE_EXT, GCODE_EXT, GDRILL_EXT, GEDGE_EXT, DRILL_UNIT, EDGE_UNIT, CUT_FLAG, CUT_OV
|
||||||
global GERBER_DIR,FRONT_FILE,BACK_FILE,DRILL_FILE,EDGE_FILE,MIRROR_FRONT,MIRROR_BACK,MIRROR_DRILL,MIRROR_EDGE,ROT_ANG
|
global GERBER_DIR,FRONT_FILE,BACK_FILE,DRILL_FILE,EDGE_FILE,MIRROR_FRONT,MIRROR_BACK,MIRROR_DRILL,MIRROR_EDGE,ROT_ANG
|
||||||
global OUT_DIR,OUT_FRONT_FILE,OUT_FRONT_2PASS_FILE,OUT_FRONT_3PASS_FILE,OUT_BACK_FILE,OUT_BACK_2PASS_FILE,OUT_BACK_3PASS_FILE,OUT_DRILL_FILE,OUT_EDGE_FILE
|
global OUT_DIR,OUT_FRONT_FILE,OUT_FRONT_2PASS_FILE,OUT_FRONT_3PASS_FILE,OUT_BACK_FILE,OUT_BACK_2PASS_FILE,OUT_BACK_3PASS_FILE,OUT_DRILL_FILE,OUT_EDGE_FILE
|
||||||
try:
|
with open(config_file,'r') as f:
|
||||||
f = open(config_file,'r')
|
|
||||||
except IOError, (errno, strerror):
|
|
||||||
print "Unable to open the file =" + config_file + "\n"
|
|
||||||
else:
|
|
||||||
while 1:
|
while 1:
|
||||||
config = f.readline()
|
config = f.readline()
|
||||||
#print config
|
#print(config
|
||||||
if not config:
|
if not config:
|
||||||
break
|
break
|
||||||
#cfg = re.search("([A-Z\_]+)[\d\s\ ]*\=[\ \"]*([\s\/\-\d\.\_]+)\"*",config)
|
#cfg = re.search("([A-Z\_]+)[\d\s\ ]*\=[\ \"]*([\s\/\-\d\.\_]+)\"*",config)
|
||||||
cfg = re.search("([A-Z0-9\_]+)[\d\s\ ]*\=[\ \"]*([^\ \"\n\r]+)\"*",config) # FIXED: Now variable names can have numbers
|
cfg = re.search("([A-Z0-9\_]+)[\d\s\ ]*\=[\ \"]*([^\ \"\n\r]+)\"*",config) # FIXED: Now variable names can have numbers
|
||||||
if (cfg):
|
if (cfg):
|
||||||
#print str(cfg.group(1)),"=",str(cfg.group(2))
|
#print(str(cfg.group(1)),"=",str(cfg.group(2))
|
||||||
if(cfg.group(1)=="INI_X"):
|
if(cfg.group(1)=="INI_X"):
|
||||||
#print "ini x =",cfg.group(2)
|
#print("ini x =",cfg.group(2)
|
||||||
INI_X = float(cfg.group(2))
|
INI_X = float(cfg.group(2))
|
||||||
if(cfg.group(1)=="INI_Y"):
|
if(cfg.group(1)=="INI_Y"):
|
||||||
INI_Y = float(cfg.group(2))
|
INI_Y = float(cfg.group(2))
|
||||||
|
@ -450,10 +446,10 @@ def read_config(config_file):
|
||||||
GEDGE_EXT = str(cfg.group(2))
|
GEDGE_EXT = str(cfg.group(2))
|
||||||
|
|
||||||
if(cfg.group(1)=="GERBER_DIR"):
|
if(cfg.group(1)=="GERBER_DIR"):
|
||||||
#print "dir =",cfg.group(2)
|
#print("dir =",cfg.group(2)
|
||||||
GERBER_DIR = str(cfg.group(2))
|
GERBER_DIR = str(cfg.group(2))
|
||||||
if(cfg.group(1)=="FRONT_FILE"):
|
if(cfg.group(1)=="FRONT_FILE"):
|
||||||
#print "front =",cfg.group(2)
|
#print("front =",cfg.group(2)
|
||||||
FRONT_FILE = str(cfg.group(2))
|
FRONT_FILE = str(cfg.group(2))
|
||||||
if(cfg.group(1)=="BACK_FILE"):
|
if(cfg.group(1)=="BACK_FILE"):
|
||||||
BACK_FILE = str(cfg.group(2))
|
BACK_FILE = str(cfg.group(2))
|
||||||
|
@ -490,6 +486,8 @@ def read_config(config_file):
|
||||||
if(cfg.group(1)=="OUT_EDGE_FILE"):
|
if(cfg.group(1)=="OUT_EDGE_FILE"):
|
||||||
OUT_EDGE_FILE = str(cfg.group(2))
|
OUT_EDGE_FILE = str(cfg.group(2))
|
||||||
f.close()
|
f.close()
|
||||||
|
return
|
||||||
|
raise Exception("Unable to open the file " + config_file + "\n")
|
||||||
|
|
||||||
def set_unit():
|
def set_unit():
|
||||||
global IN_INCH_FLAG, OUT_INCH_FLAG, gUNIT, INCH
|
global IN_INCH_FLAG, OUT_INCH_FLAG, gUNIT, INCH
|
||||||
|
@ -542,26 +540,26 @@ def read_Gerber(dirname,filename):
|
||||||
#global IN_INCH_FLAG
|
#global IN_INCH_FLAG
|
||||||
global gGCODES
|
global gGCODES
|
||||||
gGCODES = []
|
gGCODES = []
|
||||||
print "Parse Gerber data"
|
print("Parse Gerber data")
|
||||||
(data,f) = open_file(dirname, filename)
|
(data,f) = open_file(dirname, filename)
|
||||||
for gerber in data:
|
for gerber in data:
|
||||||
if not gerber:
|
if not gerber:
|
||||||
break
|
break
|
||||||
# print gerber
|
# print(gerber
|
||||||
if (find(gerber, "%MOIN") != -1):
|
if (gerber.find("%MOIN") != -1):
|
||||||
IN_INCH_FLAG = 1
|
IN_INCH_FLAG = 1
|
||||||
|
|
||||||
if (find(gerber, "%ADD") != -1):
|
if (gerber.find("%ADD") != -1):
|
||||||
parse_add(gerber)
|
parse_add(gerber)
|
||||||
if(find(gerber, "%AM") != -1):
|
if(gerber.find("%AM") != -1):
|
||||||
#do nothing
|
#do nothing
|
||||||
print "Ignoring %AM..."
|
print("Ignoring %AM...")
|
||||||
if (find(gerber, "D") == 0):
|
if (gerber.find("D") == 0):
|
||||||
parse_d(gerber)
|
parse_d(gerber)
|
||||||
if (find(gerber, "G") != -1):
|
if (gerber.find("G") != -1):
|
||||||
parse_g(gerber)
|
parse_g(gerber)
|
||||||
#if (find(gerber, "X") != -1 or find(gerber, "Y") != -1):
|
#if (find(gerber, "X") != -1 or find(gerber, "Y") != -1):
|
||||||
if (find(gerber, "X") == 0):
|
if (gerber.find("X") == 0):
|
||||||
parse_xy(gerber)
|
parse_xy(gerber)
|
||||||
f.close()
|
f.close()
|
||||||
return gGCODES
|
return gGCODES
|
||||||
|
@ -586,16 +584,16 @@ def parse_add(gerber):
|
||||||
gDCODE[int(d_num)] = D_DATA(aperture_type,mod1,mod2)
|
gDCODE[int(d_num)] = D_DATA(aperture_type,mod1,mod2)
|
||||||
def parse_d(gerber):
|
def parse_d(gerber):
|
||||||
global g54_FLAG, gFIG_NUM
|
global g54_FLAG, gFIG_NUM
|
||||||
#print gerber
|
#print(gerber
|
||||||
index_d=find(gerber, "D")
|
index_d=gerber.find("D")
|
||||||
index_ast=find(gerber, "*")
|
index_ast=gerber.find("*")
|
||||||
g54_FLAG = 1
|
g54_FLAG = 1
|
||||||
gFIG_NUM=gerber[index_d+1:index_ast]
|
gFIG_NUM=gerber[index_d+1:index_ast]
|
||||||
def parse_g(gerber):
|
def parse_g(gerber):
|
||||||
global gTMP_X, gTMP_Y, gTMP_Z, g54_FLAG, gFIG_NUM
|
global gTMP_X, gTMP_Y, gTMP_Z, g54_FLAG, gFIG_NUM
|
||||||
index_d=find(gerber, "D")
|
index_d=gerber.find("D")
|
||||||
index_ast=find(gerber, "*")
|
index_ast=gerber.find("*")
|
||||||
if (find(gerber, "54",1,index_d) !=-1):
|
if (gerber.find("54",1,index_d) !=-1):
|
||||||
g54_FLAG = 1
|
g54_FLAG = 1
|
||||||
else:
|
else:
|
||||||
g54_FLAG = 0
|
g54_FLAG = 0
|
||||||
|
@ -641,8 +639,8 @@ def parse_data(x,y,d):
|
||||||
gGCODES.append(GCODE(x,y,0,0,2,mod1,mod2))
|
gGCODES.append(GCODE(x,y,0,0,2,mod1,mod2))
|
||||||
elif(gDCODE[int(gFIG_NUM)].atype == "O"):
|
elif(gDCODE[int(gFIG_NUM)].atype == "O"):
|
||||||
gGCODES.append(GCODE(x,y,0,0,6,mod1,mod2))
|
gGCODES.append(GCODE(x,y,0,0,6,mod1,mod2))
|
||||||
#print "Oval 03"
|
#print("Oval 03"
|
||||||
else: print "UNSUPPORTED SHAPE TYPE:",gDCODE[int(gFIG_NUM)].atype
|
else: print("UNSUPPORTED SHAPE TYPE: " + str(gDCODE[int(gFIG_NUM)].atype))
|
||||||
elif(d == "02" or d == "2"):
|
elif(d == "02" or d == "2"):
|
||||||
#move w light off
|
#move w light off
|
||||||
gGERBER_TMP_X = x
|
gGERBER_TMP_X = x
|
||||||
|
@ -656,8 +654,8 @@ def parse_data(x,y,d):
|
||||||
gGCODES.append(GCODE(gGERBER_TMP_X,gGERBER_TMP_Y,x,y,4,mod1,mod2))
|
gGCODES.append(GCODE(gGERBER_TMP_X,gGERBER_TMP_Y,x,y,4,mod1,mod2))
|
||||||
elif(gDCODE[int(gFIG_NUM)].atype == "O"):
|
elif(gDCODE[int(gFIG_NUM)].atype == "O"):
|
||||||
gGCODES.append(GCODE(gGERBER_TMP_X,gGERBER_TMP_Y,x,y,4,mod1,mod2)) # TODO FIX: This oval will be shown as a rectangle!
|
gGCODES.append(GCODE(gGERBER_TMP_X,gGERBER_TMP_Y,x,y,4,mod1,mod2)) # TODO FIX: This oval will be shown as a rectangle!
|
||||||
print "Oval pad will appear as a rectangle!"
|
print("Oval pad will appear as a rectangle!")
|
||||||
else: print "UNSUPPORTED SHAPE TYPE:",gDCODE[int(gFIG_NUM)].atype
|
else: print("UNSUPPORTED SHAPE TYPE: " + str(gDCODE[int(gFIG_NUM)].atype))
|
||||||
gGERBER_TMP_X = x
|
gGERBER_TMP_X = x
|
||||||
gGERBER_TMP_Y = y
|
gGERBER_TMP_Y = y
|
||||||
|
|
||||||
|
@ -760,7 +758,7 @@ def polygon(points):
|
||||||
y_max=-HUGE
|
y_max=-HUGE
|
||||||
y_min=HUGE
|
y_min=HUGE
|
||||||
if(len(points)<=2):
|
if(len(points)<=2):
|
||||||
print "Error: polygon point"
|
print("Error: polygon point")
|
||||||
return
|
return
|
||||||
i = 0
|
i = 0
|
||||||
while i< len(points):
|
while i< len(points):
|
||||||
|
@ -794,12 +792,12 @@ def circle_points(cx,cy,r,points_num):
|
||||||
elif new_points_num > 50 :
|
elif new_points_num > 50 :
|
||||||
new_points_num = 50
|
new_points_num = 50
|
||||||
|
|
||||||
#print "Modifying CIRCLE points_num from",points_num,"to",new_points_num
|
#print("Modifying CIRCLE points_num from",points_num,"to",new_points_num
|
||||||
points_num = new_points_num
|
points_num = new_points_num
|
||||||
# print "Circle: Radius:", str(r), "Points:", points_num
|
# print("Circle: Radius:", str(r), "Points:", points_num
|
||||||
points=[]
|
points=[]
|
||||||
# if(points_num <= 2):
|
# if(points_num <= 2):
|
||||||
# print "Too small angle at Circle"
|
# print("Too small angle at Circle"
|
||||||
# return
|
# return
|
||||||
i = points_num
|
i = points_num
|
||||||
while i > 0:
|
while i > 0:
|
||||||
|
@ -867,15 +865,15 @@ def end(front_poly,back_poly,front_poly_2pass,back_poly_2pass,front_poly_3pass,b
|
||||||
|
|
||||||
def polygon2gcode(gPOLYGONS,height,xy_speed,z_speed):
|
def polygon2gcode(gPOLYGONS,height,xy_speed,z_speed):
|
||||||
#global gPOLYGONS
|
#global gPOLYGONS
|
||||||
print "Convert to G-code"
|
print("Convert to G-code")
|
||||||
#print len(gPOLYGONS)
|
#print(len(gPOLYGONS)
|
||||||
#i=0
|
#i=0
|
||||||
ret_data = ""
|
ret_data = ""
|
||||||
for poly in gPOLYGONS:
|
for poly in gPOLYGONS:
|
||||||
if (poly.delete):
|
if (poly.delete):
|
||||||
continue
|
continue
|
||||||
ret_data += path(height,xy_speed,z_speed,poly.points)
|
ret_data += path(height,xy_speed,z_speed,poly.points)
|
||||||
#print i
|
#print(i
|
||||||
#i+=1
|
#i+=1
|
||||||
return ret_data
|
return ret_data
|
||||||
def path(height,xy_speed,z_speed,points):
|
def path(height,xy_speed,z_speed,points):
|
||||||
|
@ -884,7 +882,7 @@ def path(height,xy_speed,z_speed,points):
|
||||||
out_data = "G1"
|
out_data = "G1"
|
||||||
gcode_tmp_flag = 0
|
gcode_tmp_flag = 0
|
||||||
if(len(points) % 2):
|
if(len(points) % 2):
|
||||||
print "Number of points is illegal "
|
print("Number of points is illegal ")
|
||||||
#move to Start position
|
#move to Start position
|
||||||
ret_data += move(points[0]+float(gXSHIFT),points[1]+float(gYSHIFT))
|
ret_data += move(points[0]+float(gXSHIFT),points[1]+float(gYSHIFT))
|
||||||
#move to cuting heght
|
#move to cuting heght
|
||||||
|
@ -910,7 +908,7 @@ def path(height,xy_speed,z_speed,points):
|
||||||
out_data ="G1"
|
out_data ="G1"
|
||||||
gcode_tmp_flag=0
|
gcode_tmp_flag=0
|
||||||
i += 2
|
i += 2
|
||||||
#print gFRONT_DATA
|
#print(gFRONT_DATA
|
||||||
return ret_data
|
return ret_data
|
||||||
def move(x,y):
|
def move(x,y):
|
||||||
global gFRONT_DATA, MOVE_HEIGHT, gTMP_X, gTMP_Y, gTMP_Z
|
global gFRONT_DATA, MOVE_HEIGHT, gTMP_X, gTMP_Y, gTMP_Z
|
||||||
|
@ -947,15 +945,15 @@ def arc_points(cx,cy,r,s_angle,e_angle,kaku):
|
||||||
elif new_kaku > 50 :
|
elif new_kaku > 50 :
|
||||||
new_kaku = 50
|
new_kaku = 50
|
||||||
if kaku != new_kaku:
|
if kaku != new_kaku:
|
||||||
#print "Modifying ARC points from",kaku,"to",new_kaku
|
#print("Modifying ARC points from",kaku,"to",new_kaku
|
||||||
kaku = new_kaku
|
kaku = new_kaku
|
||||||
# print "Arc: Radius:", str(r), "Points:", kaku
|
# print("Arc: Radius:", str(r), "Points:", kaku
|
||||||
|
|
||||||
points=[]
|
points=[]
|
||||||
if(s_angle == e_angle):
|
if(s_angle == e_angle):
|
||||||
print "Start and End angle are same"
|
print("Start and End angle are same")
|
||||||
if(kaku <= 2):
|
if(kaku <= 2):
|
||||||
print "Too small angle"
|
print("Too small angle")
|
||||||
arc_x=float(cx+r*cos(float(s_angle))) # Draw a line
|
arc_x=float(cx+r*cos(float(s_angle))) # Draw a line
|
||||||
arc_y=float(cy+r*sin(float(s_angle)))
|
arc_y=float(cy+r*sin(float(s_angle)))
|
||||||
points.extend([arc_x,arc_y])
|
points.extend([arc_x,arc_y])
|
||||||
|
@ -977,7 +975,7 @@ def calc_shift():
|
||||||
global gXSHIFT, gYSHIFT, gXMIN, gYMIN, LEFT_X, LOWER_Y
|
global gXSHIFT, gYSHIFT, gXMIN, gYMIN, LEFT_X, LOWER_Y
|
||||||
gXSHIFT = LEFT_X - gXMIN
|
gXSHIFT = LEFT_X - gXMIN
|
||||||
gYSHIFT = LOWER_Y - gYMIN
|
gYSHIFT = LOWER_Y - gYMIN
|
||||||
#print "x_shift=" + str(gXSHIFT) + "y_shift=" + str(gYSHIFT)
|
#print("x_shift=" + str(gXSHIFT) + "y_shift=" + str(gYSHIFT)
|
||||||
|
|
||||||
def polygon2line(points,sw):
|
def polygon2line(points,sw):
|
||||||
global gLINES,gLINES2
|
global gLINES,gLINES2
|
||||||
|
@ -1028,7 +1026,7 @@ def mirror_poly(polygons):
|
||||||
i += 2
|
i += 2
|
||||||
return polygons
|
return polygons
|
||||||
def rot_point(x,y):
|
def rot_point(x,y):
|
||||||
#print "rot ang =",ang
|
#print("rot ang =",ang
|
||||||
add_ang = pi * float(ROT_ANG)/180
|
add_ang = pi * float(ROT_ANG)/180
|
||||||
xc = (gXMIN+gXMAX)/2
|
xc = (gXMIN+gXMAX)/2
|
||||||
yc = (gYMIN+gYMAX)/2
|
yc = (gYMIN+gYMAX)/2
|
||||||
|
@ -1039,7 +1037,7 @@ def rot_point(x,y):
|
||||||
rot_ang = ini_ang + add_ang
|
rot_ang = ini_ang + add_ang
|
||||||
new_x =xc + r * cos(rot_ang)
|
new_x =xc + r * cos(rot_ang)
|
||||||
new_y =yc + r * sin(rot_ang)
|
new_y =yc + r * sin(rot_ang)
|
||||||
#print new_x
|
#print(new_x
|
||||||
return new_x,new_y
|
return new_x,new_y
|
||||||
|
|
||||||
def mirror_point(x,y):
|
def mirror_point(x,y):
|
||||||
|
@ -1051,7 +1049,7 @@ def mirror_point(x,y):
|
||||||
def read_Drill_file(dirname,drill_file):
|
def read_Drill_file(dirname,drill_file):
|
||||||
global gDRILL_D, gDRILL_TYPE, DRILL_UNIT,gUNIT,INCH
|
global gDRILL_D, gDRILL_TYPE, DRILL_UNIT,gUNIT,INCH
|
||||||
(data,f) = open_file(dirname, drill_file)
|
(data,f) = open_file(dirname, drill_file)
|
||||||
print "Read and Parse Drill data"
|
print("Read and Parse Drill data")
|
||||||
drill_d_unit = DRILL_UNIT
|
drill_d_unit = DRILL_UNIT
|
||||||
for drill in data:
|
for drill in data:
|
||||||
if not drill:
|
if not drill:
|
||||||
|
@ -1061,24 +1059,24 @@ def read_Drill_file(dirname,drill_file):
|
||||||
if(drill_data):
|
if(drill_data):
|
||||||
gDRILL_TYPE[int(drill_data.group(1))] = drill_data.group(2)
|
gDRILL_TYPE[int(drill_data.group(1))] = drill_data.group(2)
|
||||||
if(drill_num):
|
if(drill_num):
|
||||||
#print drill_d_unit
|
#print(drill_d_unit
|
||||||
gDRILL_D=float(gDRILL_TYPE[int(drill_num.group(1))]) * drill_d_unit
|
gDRILL_D=float(gDRILL_TYPE[int(drill_num.group(1))]) * drill_d_unit
|
||||||
#gDRILL_D=float(gDRILL_TYPE[int(drill_num.group(1))]) * gUNIT
|
#gDRILL_D=float(gDRILL_TYPE[int(drill_num.group(1))]) * gUNIT
|
||||||
if (find(drill, "G") != -1):
|
if (drill.find("G") != -1):
|
||||||
parse_drill_g(drill)
|
parse_drill_g(drill)
|
||||||
elif (find(drill, "X") != -1 or find(drill, "Y") != -1):
|
elif (drill.find("X") != -1 or drill.find("Y") != -1):
|
||||||
parse_drill_xy(drill)
|
parse_drill_xy(drill)
|
||||||
if (find(drill, "INCH") != -1):
|
if (drill.find("INCH") != -1):
|
||||||
drill_d_unit = INCH
|
drill_d_unit = INCH
|
||||||
#print "Drill Diameter = INCH"
|
#print("Drill Diameter = INCH"
|
||||||
if (find(drill, "M72") != -1):
|
if (drill.find("M72") != -1):
|
||||||
#print "Drill unit = INCH"
|
#print("Drill unit = INCH"
|
||||||
DRILL_UNIT = INCH
|
DRILL_UNIT = INCH
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def parse_drill_g(drill):
|
def parse_drill_g(drill):
|
||||||
global gDRILL_LINES, gDRILL_D, DRILL_UNIT
|
global gDRILL_LINES, gDRILL_D, DRILL_UNIT
|
||||||
#print "Drill G";
|
#print("Drill G";
|
||||||
#xx = re.search("X([\d\.-]+)\D",drill)
|
#xx = re.search("X([\d\.-]+)\D",drill)
|
||||||
#yy = re.search("Y([\d\.-]+)\D",drill)
|
#yy = re.search("Y([\d\.-]+)\D",drill)
|
||||||
xy = re.search("X([\d\.-]+)Y([\d\.-]+)\D[\d]+X([\d\.-]+)Y([\d\.-]+)",drill)
|
xy = re.search("X([\d\.-]+)Y([\d\.-]+)\D[\d]+X([\d\.-]+)Y([\d\.-]+)",drill)
|
||||||
|
@ -1091,8 +1089,8 @@ def parse_drill_g(drill):
|
||||||
y1=float(xy.group(2)) * DRILL_UNIT
|
y1=float(xy.group(2)) * DRILL_UNIT
|
||||||
x2=float(xy.group(3)) * DRILL_UNIT
|
x2=float(xy.group(3)) * DRILL_UNIT
|
||||||
y2=float(xy.group(4)) * DRILL_UNIT
|
y2=float(xy.group(4)) * DRILL_UNIT
|
||||||
#print "x1=" + str(x1) + "y1=" + str(y1) + "x2=" + str(x2) + "y2=" + str(y2)
|
#print("x1=" + str(x1) + "y1=" + str(y1) + "x2=" + str(x2) + "y2=" + str(y2)
|
||||||
#print "gDRILL_D =",gDRILL_D
|
#print("gDRILL_D =",gDRILL_D
|
||||||
gDRILL_LINES.append(DRILL_LINE(x1,y1,x2,y2,gDRILL_D,0))
|
gDRILL_LINES.append(DRILL_LINE(x1,y1,x2,y2,gDRILL_D,0))
|
||||||
|
|
||||||
def parse_drill_xy(drill):
|
def parse_drill_xy(drill):
|
||||||
|
@ -1103,7 +1101,7 @@ def parse_drill_xy(drill):
|
||||||
x=float(xx.group(1)) * DRILL_UNIT
|
x=float(xx.group(1)) * DRILL_UNIT
|
||||||
if(yy):
|
if(yy):
|
||||||
y=float(yy.group(1)) * DRILL_UNIT
|
y=float(yy.group(1)) * DRILL_UNIT
|
||||||
#print "gDRILL_D =",gDRILL_D
|
#print("gDRILL_D =",gDRILL_D
|
||||||
gDRILLS.append(DRILL(x,y,gDRILL_D,0))
|
gDRILLS.append(DRILL(x,y,gDRILL_D,0))
|
||||||
|
|
||||||
def do_drill():
|
def do_drill():
|
||||||
|
@ -1124,12 +1122,12 @@ def do_drill():
|
||||||
x,y = mirror_point(x,y)
|
x,y = mirror_point(x,y)
|
||||||
x = x + gXSHIFT
|
x = x + gXSHIFT
|
||||||
y = y + gYSHIFT
|
y = y + gYSHIFT
|
||||||
#print "drill.d=" + str(drill.d) + ", DRILL_D=" + str(DRILL_D)
|
#print("drill.d=" + str(drill.d) + ", DRILL_D=" + str(DRILL_D)
|
||||||
#move to hole position
|
#move to hole position
|
||||||
#print "drill_d =", drill.d, " , DRILL_D =",DRILL_D
|
#print("drill_d =", drill.d, " , DRILL_D =",DRILL_D
|
||||||
if(drill.d > DRILL_D + drill_mergin):
|
if(drill.d > DRILL_D + drill_mergin):
|
||||||
cir_r = drill.d/2 - DRILL_D/2
|
cir_r = drill.d/2 - DRILL_D/2
|
||||||
#print cir_r
|
#print(cir_r
|
||||||
#drill_data += move_drill(drill.x-cir_r,drill.y)
|
#drill_data += move_drill(drill.x-cir_r,drill.y)
|
||||||
drill_data += drill_hole(x,y,cir_r)
|
drill_data += drill_hole(x,y,cir_r)
|
||||||
else:
|
else:
|
||||||
|
@ -1142,7 +1140,7 @@ def do_drill():
|
||||||
#Goto moving Z position
|
#Goto moving Z position
|
||||||
drill_data += "G0 Z" + floats(MOVE_HEIGHT) + "\n"
|
drill_data += "G0 Z" + floats(MOVE_HEIGHT) + "\n"
|
||||||
gTMP_DRILL_Z = MOVE_HEIGHT
|
gTMP_DRILL_Z = MOVE_HEIGHT
|
||||||
#print "len gDRILL_LINES=" +str(len(gDRILL_LINES))
|
#print("len gDRILL_LINES=" +str(len(gDRILL_LINES))
|
||||||
for drill_l in gDRILL_LINES:
|
for drill_l in gDRILL_LINES:
|
||||||
x1 = drill_l.x1
|
x1 = drill_l.x1
|
||||||
y1 = drill_l.y1
|
y1 = drill_l.y1
|
||||||
|
@ -1173,7 +1171,7 @@ def move_drill(x,y):
|
||||||
global MOVE_HEIGHT, gTMP_DRILL_X, gTMP_DRILL_Y, gTMP_DRILL_Z
|
global MOVE_HEIGHT, gTMP_DRILL_X, gTMP_DRILL_Y, gTMP_DRILL_Z
|
||||||
xy_data = "G0"
|
xy_data = "G0"
|
||||||
out_data = ""
|
out_data = ""
|
||||||
#print out_data
|
#print(out_data
|
||||||
gcode_tmp_flag = 0
|
gcode_tmp_flag = 0
|
||||||
if(x != gTMP_DRILL_X):
|
if(x != gTMP_DRILL_X):
|
||||||
gTMP_DRILL_X = x
|
gTMP_DRILL_X = x
|
||||||
|
@ -1255,8 +1253,8 @@ def drill_line(x1,y1,x2,y2,d):
|
||||||
tmp_y = y2
|
tmp_y = y2
|
||||||
#gDRAWDRILL_LINE.append(DRAWPOLY(points,"",0))
|
#gDRAWDRILL_LINE.append(DRAWPOLY(points,"",0))
|
||||||
out_data += "G0 X" + floats(tmp_x) + " Y" + floats(tmp_y) + "\n"
|
out_data += "G0 X" + floats(tmp_x) + " Y" + floats(tmp_y) + "\n"
|
||||||
#print z_step_n
|
#print(z_step_n
|
||||||
#print len(points)
|
#print(len(points)
|
||||||
i = 1
|
i = 1
|
||||||
while i <= z_step_n:
|
while i <= z_step_n:
|
||||||
gTMP_DRILL_Z = i*z_step
|
gTMP_DRILL_Z = i*z_step
|
||||||
|
@ -1294,7 +1292,7 @@ def drill_hole(cx,cy,r):
|
||||||
# r = r/2.0 # REDUCE DRILL SIZE
|
# r = r/2.0 # REDUCE DRILL SIZE
|
||||||
z_step_n = int(float(DRILL_DEPTH)/float(Z_STEP_DRILL)) + 1
|
z_step_n = int(float(DRILL_DEPTH)/float(Z_STEP_DRILL)) + 1
|
||||||
z_step = float(DRILL_DEPTH)/z_step_n
|
z_step = float(DRILL_DEPTH)/z_step_n
|
||||||
#print "r=" + str(r)
|
#print("r=" + str(r)
|
||||||
if(MOVE_HEIGHT != gTMP_DRILL_Z):
|
if(MOVE_HEIGHT != gTMP_DRILL_Z):
|
||||||
gTMP_DRILL_Z = MOVE_HEIGHT
|
gTMP_DRILL_Z = MOVE_HEIGHT
|
||||||
out_data += "G0 Z" + floats(gTMP_DRILL_Z) + " F" + floats(DRILL_SPEED) + "\n" # MOD
|
out_data += "G0 Z" + floats(gTMP_DRILL_Z) + " F" + floats(DRILL_SPEED) + "\n" # MOD
|
||||||
|
@ -1339,7 +1337,7 @@ def drill_hole_test(cx,cy,r):
|
||||||
gcode_tmp_flag = 0
|
gcode_tmp_flag = 0
|
||||||
z_step_n = int(DRILL_DEPTH/Z_STEP_DRILL) + 1
|
z_step_n = int(DRILL_DEPTH/Z_STEP_DRILL) + 1
|
||||||
z_step = DRILL_DEPTH/z_step_n
|
z_step = DRILL_DEPTH/z_step_n
|
||||||
#print "r=" + str(r)
|
#print("r=" + str(r)
|
||||||
if(MOVE_HEIGHT != gTMP_DRILL_Z):
|
if(MOVE_HEIGHT != gTMP_DRILL_Z):
|
||||||
gTMP_DRILL_Z = MOVE_HEIGHT
|
gTMP_DRILL_Z = MOVE_HEIGHT
|
||||||
out_data += "G0 Z" + floats(gTMP_DRILL_Z) + "\n"
|
out_data += "G0 Z" + floats(gTMP_DRILL_Z) + "\n"
|
||||||
|
@ -1441,9 +1439,9 @@ def edge2gcode():
|
||||||
points = edge.points
|
points = edge.points
|
||||||
if(len(points) % 2):
|
if(len(points) % 2):
|
||||||
error_dialog("Error:Number of points is illegal ",0)
|
error_dialog("Error:Number of points is illegal ",0)
|
||||||
#print "Number of points is illegal "
|
#print("Number of points is illegal "
|
||||||
#print "x=" + str(gTMP_EDGE_X) + ", y=" + str(gTMP_EDGE_Y)
|
#print("x=" + str(gTMP_EDGE_X) + ", y=" + str(gTMP_EDGE_Y)
|
||||||
#print "x=" + str(float(points[0])+float(gXSHIFT)) + ", y=" + str(float(points[1])+float(gYSHIFT))
|
#print("x=" + str(float(points[0])+float(gXSHIFT)) + ", y=" + str(float(points[1])+float(gYSHIFT))
|
||||||
#move to Start position
|
#move to Start position
|
||||||
gEDGE_DATA += move_edge(float(points[0]),float(points[1]))
|
gEDGE_DATA += move_edge(float(points[0]),float(points[1]))
|
||||||
#move to cuting heght
|
#move to cuting heght
|
||||||
|
@ -1486,7 +1484,7 @@ def move_edge(x,y):
|
||||||
y=y+float(gYSHIFT)
|
y=y+float(gYSHIFT)
|
||||||
xy_data = "G0"
|
xy_data = "G0"
|
||||||
out_data = ""
|
out_data = ""
|
||||||
#print out_data
|
#print(out_data
|
||||||
gcode_tmp_flag = 0
|
gcode_tmp_flag = 0
|
||||||
if(x != gTMP_EDGE_X):
|
if(x != gTMP_EDGE_X):
|
||||||
gTMP_EDGE_X = x
|
gTMP_EDGE_X = x
|
||||||
|
@ -1514,14 +1512,10 @@ def points_revers(points):
|
||||||
return return_points
|
return return_points
|
||||||
def open_file(dirname, filename):
|
def open_file(dirname, filename):
|
||||||
file_name = os.path.join(dirname, filename)
|
file_name = os.path.join(dirname, filename)
|
||||||
try:
|
with open(file_name,'r') as f:
|
||||||
f = open(file_name,'r')
|
|
||||||
except IOError, (errno, strerror):
|
|
||||||
print "Unable to open the file" + file_name + "\n"
|
|
||||||
return []
|
|
||||||
else:
|
|
||||||
ret = f.read()
|
ret = f.read()
|
||||||
return (ret.split("\n"),f)
|
return (ret.split("\n"),f)
|
||||||
|
raise Exception("Unable to open the file " + file_name + "\n")
|
||||||
def write_file(dirname,filename,datas):
|
def write_file(dirname,filename,datas):
|
||||||
file_name = os.path.join(dirname, filename)
|
file_name = os.path.join(dirname, filename)
|
||||||
if(datas):
|
if(datas):
|
||||||
|
@ -1529,6 +1523,6 @@ def write_file(dirname,filename,datas):
|
||||||
f.write(datas)
|
f.write(datas)
|
||||||
f.close()
|
f.close()
|
||||||
else:
|
else:
|
||||||
print "ERROR : No save data"
|
print("ERROR : No save data")
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Binary file not shown.
|
@ -13,8 +13,8 @@ GRID_N_POINTS = (4,4) # Number of points (AT LEAST 4 IN EACH DIRECTION, OTHERWIS
|
||||||
Zlift = 0.5 # mm # Lift between probings, it is relative so should be enough
|
Zlift = 0.5 # mm # Lift between probings, it is relative so should be enough
|
||||||
|
|
||||||
# For Zprobe and Send
|
# For Zprobe and Send
|
||||||
F_fastMove = 700 # mm/s
|
F_fastMove = 70000 # mm/s
|
||||||
F_slowMove = 200 # mm/s
|
F_slowMove = 20000 # mm/s
|
||||||
initial_Z_lowering_distance = -5 # Warning: Do not lower too much or you will potentially cause damage!
|
initial_Z_lowering_distance = -5 # Warning: Do not lower too much or you will potentially cause damage!
|
||||||
|
|
||||||
N_copies_X = 2 # Panelizing options!
|
N_copies_X = 2 # Panelizing options!
|
||||||
|
|
|
@ -12,13 +12,13 @@ import pickle # For file saving
|
||||||
|
|
||||||
def saveToFile(data,path):
|
def saveToFile(data,path):
|
||||||
with open(path, 'wb') as path_file:
|
with open(path, 'wb') as path_file:
|
||||||
ret = pickle.dump(data, path_file)
|
ret = pickle.dump(data, path_file, protocol=2)
|
||||||
path_file.close()
|
path_file.close()
|
||||||
return ret
|
return ret
|
||||||
raise Exception("Could not save " + path)
|
raise Exception("Could not save " + path)
|
||||||
|
|
||||||
def loadFromFile(path):
|
def loadFromFile(path):
|
||||||
with open(path) as path_file:
|
with open(path, 'rb') as path_file:
|
||||||
ret = pickle.load(path_file)
|
ret = pickle.load(path_file)
|
||||||
path_file.close()
|
path_file.close()
|
||||||
return ret
|
return ret
|
||||||
|
|
Loading…
Reference in New Issue