Skip to content

Commit

Permalink
Unify tool output between milling and drilling
Browse files Browse the repository at this point in the history
In #236 the following script is proposed to split the mill files into one for each tool (cutter diameter):
https://github.com/pcb2gcode/pcb2gcode/files/2914413/split-gcode.txt

This script does not work as-is for drill files to split them into individual files for differently sized drills. The reason is that tool size messages are formatted differently, for example:
```(MSG, Change tool bit to drill size 0.4 mm)```
vs:
```(MSG, Change tool bit to mill diameter 1.20000mm)```

Notice the additional space in the drill tool change message.

This patch removes the space between diameter and unit for drill size output, making the script usable for both drill and mill files.
  • Loading branch information
hannesweisbach authored and eyal0 committed Oct 9, 2020
1 parent 4b4e092 commit abafbab
Show file tree
Hide file tree
Showing 30 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion drill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ string ExcellonProcessor::drill_to_string(drillbit drillbit) {
}
auto unit = bMetricOutput ? "mm" : "inch";
std::ostringstream ss;
ss << diameter << " " << unit;
ss << diameter << unit;
return ss.str();
}

Expand Down
10 changes: 5 additions & 5 deletions testing/gerbv_example/milldrilldiatest/expected/drill.ngc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
( Software-independent Gcode )

( This file uses 4 drill bit sizes. )
( Bit sizes: [0.4 mm] [0.6 mm] [0.8 mm] [1 mm] )
( Bit sizes: [0.4mm] [0.6mm] [0.8mm] [1mm] )

G94 (Millimeters per minute feed rate.)
G21 (Units == Millimeters.)
Expand All @@ -14,7 +14,7 @@ G00 Z10.00000 (Retract)
T1
M5 (Spindle stop.)
G04 P1.00000
(MSG, Change tool bit to drill size 0.4 mm)
(MSG, Change tool bit to drill size 0.4mm)
M6 (Tool change.)
M0 (Temporary machine stop.)
M3 (Spindle on clockwise.)
Expand All @@ -29,7 +29,7 @@ G00 Z10.00000 (Retract)
T3
M5 (Spindle stop.)
G04 P1.00000
(MSG, Change tool bit to drill size 0.6 mm)
(MSG, Change tool bit to drill size 0.6mm)
M6 (Tool change.)
M0 (Temporary machine stop.)
M3 (Spindle on clockwise.)
Expand All @@ -43,7 +43,7 @@ G00 Z10.00000 (Retract)
T4
M5 (Spindle stop.)
G04 P1.00000
(MSG, Change tool bit to drill size 0.8 mm)
(MSG, Change tool bit to drill size 0.8mm)
M6 (Tool change.)
M0 (Temporary machine stop.)
M3 (Spindle on clockwise.)
Expand All @@ -57,7 +57,7 @@ G00 Z10.00000 (Retract)
T5
M5 (Spindle stop.)
G04 P1.00000
(MSG, Change tool bit to drill size 1 mm)
(MSG, Change tool bit to drill size 1mm)
M6 (Tool change.)
M0 (Temporary machine stop.)
M3 (Spindle on clockwise.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 1.00000mm to drill the 5 hole sizes. )
( Hole sizes: [1.2 mm] [1.4 mm] [1.6 mm] [1.8 mm] [2 mm] )
( Hole sizes: [1.2mm] [1.4mm] [1.6mm] [1.8mm] [2mm] )

G94 (Millimeters per minute feed rate.)
G21 (Units == Millimeters.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.03150inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0394094 inch] )
( Hole sizes: [0.0314961inch] [0.0394094inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.07087inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0787795 inch] )
( Hole sizes: [0.0314961inch] [0.0787795inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.03150inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0394094 inch] )
( Hole sizes: [0.0314961inch] [0.0394094inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.03150inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0394094 inch] )
( Hole sizes: [0.0314961inch] [0.0394094inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Gcode for linuxcnc )
( This file uses a mill head of 0.03150inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0394094 inch] )
( Hole sizes: [0.0314961inch] [0.0394094inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.03150inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0394094 inch] )
( Hole sizes: [0.0314961inch] [0.0394094inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.03150inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0394094 inch] )
( Hole sizes: [0.0314961inch] [0.0394094inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.03150inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0394094 inch] )
( Hole sizes: [0.0314961inch] [0.0394094inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.03150inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0394094 inch] )
( Hole sizes: [0.0314961inch] [0.0394094inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.03150inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0394094 inch] )
( Hole sizes: [0.0314961inch] [0.0394094inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.03150inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0394094 inch] )
( Hole sizes: [0.0314961inch] [0.0394094inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.03150inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0394094 inch] )
( Hole sizes: [0.0314961inch] [0.0394094inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.03150inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0394094 inch] )
( Hole sizes: [0.0314961inch] [0.0394094inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
2 changes: 1 addition & 1 deletion testing/gerbv_example/multivibrator/expected/milldrill.ngc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.03150inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0394094 inch] )
( Hole sizes: [0.0314961inch] [0.0394094inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.03150inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0394094 inch] )
( Hole sizes: [0.0314961inch] [0.0394094inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.03150inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0394094 inch] )
( Hole sizes: [0.0314961inch] [0.0394094inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.03150inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0394094 inch] )
( Hole sizes: [0.0314961inch] [0.0394094inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.03150inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0394094 inch] )
( Hole sizes: [0.0314961inch] [0.0394094inch] )

( preamble-text line1 )
( preamble-text line2 )
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.03150inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0394094 inch] )
( Hole sizes: [0.0314961inch] [0.0394094inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.03150inch to drill the 2 hole sizes. )
( Hole sizes: [0.0314961 inch] [0.0394094 inch] )
( Hole sizes: [0.0314961inch] [0.0394094inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 2.54000mm to drill the 3 hole sizes. )
( Hole sizes: [0.4 mm] [1.001 mm] [3 mm] )
( Hole sizes: [0.4mm] [1.001mm] [3mm] )

G94 (Millimeters per minute feed rate.)
G21 (Units == Millimeters.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.10000inch to drill the 3 hole sizes. )
( Hole sizes: [0.015748 inch] [0.0394094 inch] [0.11811 inch] )
( Hole sizes: [0.015748inch] [0.0394094inch] [0.11811inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
( Software-independent Gcode )

( This file uses 1 drill bit sizes. )
( Bit sizes: [0.015748 inch] )
( Bit sizes: [0.015748inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand All @@ -14,7 +14,7 @@ G00 Z1.00000 (Retract)
T1
M5 (Spindle stop.)
G04 P1.00000
(MSG, Change tool bit to drill size 0.015748 inch)
(MSG, Change tool bit to drill size 0.015748inch)
M6 (Tool change.)
M0 (Temporary machine stop.)
M3 (Spindle on clockwise.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( pcb2gcode 2.1.0 )
( Software-independent Gcode )
( This file uses a mill head of 0.04000inch to drill the 2 hole sizes. )
( Hole sizes: [0.0394094 inch] [0.11811 inch] )
( Hole sizes: [0.0394094inch] [0.11811inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ G53 G00 Z25.40000 (Retract)
T1
M5 (Spindle stop.)
G04 P1.00000
(MSG, Change tool bit to drill size 0.4064 mm)
(MSG, Change tool bit to drill size 0.4064mm)
M6 (Tool change.)
M0 (Temporary machine stop.)
M3 (Spindle on clockwise.)
Expand Down
8 changes: 4 additions & 4 deletions testing/gerbv_example/slots-with-drill/expected/drill.ngc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
( Software-independent Gcode )

( This file uses 3 drill bit sizes. )
( Bit sizes: [0.015748 inch] [0.0394094 inch] [0.11811 inch] )
( Bit sizes: [0.015748inch] [0.0394094inch] [0.11811inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand All @@ -14,7 +14,7 @@ G00 Z1.00000 (Retract)
T1
M5 (Spindle stop.)
G04 P1.00000
(MSG, Change tool bit to drill size 0.015748 inch)
(MSG, Change tool bit to drill size 0.015748inch)
M6 (Tool change.)
M0 (Temporary machine stop.)
M3 (Spindle on clockwise.)
Expand All @@ -37,7 +37,7 @@ G00 Z1.00000 (Retract)
T2
M5 (Spindle stop.)
G04 P1.00000
(MSG, Change tool bit to drill size 0.0394094 inch)
(MSG, Change tool bit to drill size 0.0394094inch)
M6 (Tool change.)
M0 (Temporary machine stop.)
M3 (Spindle on clockwise.)
Expand Down Expand Up @@ -82,7 +82,7 @@ G00 Z1.00000 (Retract)
T3
M5 (Spindle stop.)
G04 P1.00000
(MSG, Change tool bit to drill size 0.11811 inch)
(MSG, Change tool bit to drill size 0.11811inch)
M6 (Tool change.)
M0 (Temporary machine stop.)
M3 (Spindle on clockwise.)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
( Software-independent Gcode )

( This file uses 3 drill bit sizes. )
( Bit sizes: [0.01 inch] [0.0394094 inch] [0.11811 inch] )
( Bit sizes: [0.01inch] [0.0394094inch] [0.11811inch] )

G94 (Inches per minute feed rate.)
G20 (Units == INCHES.)
Expand All @@ -14,7 +14,7 @@ G00 Z1.00000 (Retract)
T1
M5 (Spindle stop.)
G04 P1.00000
(MSG, Change tool bit to drill size 0.01 inch)
(MSG, Change tool bit to drill size 0.01inch)
M6 (Tool change.)
M0 (Temporary machine stop.)
M3 (Spindle on clockwise.)
Expand All @@ -37,7 +37,7 @@ G00 Z1.00000 (Retract)
T2
M5 (Spindle stop.)
G04 P1.00000
(MSG, Change tool bit to drill size 0.0394094 inch)
(MSG, Change tool bit to drill size 0.0394094inch)
M6 (Tool change.)
M0 (Temporary machine stop.)
M3 (Spindle on clockwise.)
Expand Down Expand Up @@ -82,7 +82,7 @@ G00 Z1.00000 (Retract)
T3
M5 (Spindle stop.)
G04 P1.00000
(MSG, Change tool bit to drill size 0.11811 inch)
(MSG, Change tool bit to drill size 0.11811inch)
M6 (Tool change.)
M0 (Temporary machine stop.)
M3 (Spindle on clockwise.)
Expand Down

0 comments on commit abafbab

Please sign in to comment.