Skip to content

Commit

Permalink
Fix "Can't compare with units and without." exception
Browse files Browse the repository at this point in the history
Enabling milldrill-diameter and min-milldrill-hole-diameter
makes the program abort with the following exception:

> Exporting milldrill... terminate called after throwing an instance of 'comparison_exception'
>   what():  Can't compare with units and without.

This patch fixes it.

Signed-off-by: Nicola Di Lieto <nicola.dilieto@gmail.com>
  • Loading branch information
ndilieto authored and eyal0 committed May 24, 2021
1 parent ed67bef commit dba66d2
Show file tree
Hide file tree
Showing 8 changed files with 263 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,9 +769,9 @@ map<int, multi_linestring_type_fp> ExcellonProcessor::optimize_holes(

// Holes that are larger than max_diameter or smaller than min_diameter are removed.
for (auto path = holes.begin(); path != holes.end(); ) {
const auto& bit_diameter = bits.at(path->first).as_length();
if ((max_diameter && bit_diameter >= *max_diameter) ||
(min_diameter && bit_diameter < *min_diameter)) {
const auto& bit_diameter = bits.at(path->first).as_length().asInch(inputFactor);
if ((max_diameter && bit_diameter >= (*max_diameter).asInch(inputFactor)) ||
(min_diameter && bit_diameter < (*min_diameter).asInch(inputFactor))) {
path = holes.erase(path); // remove because it's outside the range.
} else {
path++;
Expand Down
1 change: 1 addition & 0 deletions integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"mill_masking",
"mill_masking_voronoi",
"milldrilldiatest",
"milldrilldiatest_units",
"multivibrator",
"multivibrator_no_optimise",
"multivibrator_backtrack",
Expand Down
76 changes: 76 additions & 0 deletions testing/gerbv_example/milldrilldiatest_units/expected/drill.ngc
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
( pcb2gcode 2.4.0 )
( Software-independent Gcode )

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

G94 (Millimeters per minute feed rate.)
G21 (Units == Millimeters.)
G91.1 (Incremental arc distance mode.)
G90 (Absolute coordinates.)
G00 S10000 (RPM spindle speed.)

G00 Z10.00000 (Retract)
T1
M5 (Spindle stop.)
G04 P1.00000
(MSG, Change tool bit to drill size 0.4mm)
M6 (Tool change.)
M0 (Temporary machine stop.)
M3 (Spindle on clockwise.)
G0 Z1.50000
G04 P1.00000

G81 R1.50000 Z-1.75000 F100.00000 X120.00000 Y-90.00000
X120.00000 Y-92.54000
G80

G00 Z10.00000 (Retract)
T3
M5 (Spindle stop.)
G04 P1.00000
(MSG, Change tool bit to drill size 0.6mm)
M6 (Tool change.)
M0 (Temporary machine stop.)
M3 (Spindle on clockwise.)
G0 Z1.50000
G04 P1.00000

G81 R1.50000 Z-1.75000 F100.00000 X120.00000 Y-95.08000
G80

G00 Z10.00000 (Retract)
T4
M5 (Spindle stop.)
G04 P1.00000
(MSG, Change tool bit to drill size 0.8mm)
M6 (Tool change.)
M0 (Temporary machine stop.)
M3 (Spindle on clockwise.)
G0 Z1.50000
G04 P1.00000

G81 R1.50000 Z-1.75000 F100.00000 X120.00000 Y-97.62000
G80

G00 Z10.00000 (Retract)
T5
M5 (Spindle stop.)
G04 P1.00000
(MSG, Change tool bit to drill size 1mm)
M6 (Tool change.)
M0 (Temporary machine stop.)
M3 (Spindle on clockwise.)
G0 Z1.50000
G04 P1.00000

G81 R1.50000 Z-1.75000 F100.00000 X120.00000 Y-100.16000
G80

G00 Z10.000 ( All done -- retract )

M5 (Spindle off.)
G04 P1.000000
M9 (Coolant off.)
M2 (Program end.)

Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
( pcb2gcode 2.4.0 )
( Software-independent Gcode )
( This file uses a mill head of 1.00000mm to drill the 5 hole sizes. )
( Hole sizes: [1.2mm] [1.4mm] [1.6mm] [1.8mm] [2mm] )

G94 (Millimeters per minute feed rate.)
G21 (Units == Millimeters.)
G91.1 (Incremental arc distance mode.)
G90 (Absolute coordinates.)
S2000 (RPM spindle speed.)

G01 F600.00000 (Feedrate)
G00 Z10.00000 (Retract)
T6
M5 (Spindle stop.)
G04 P1.00000
(MSG, Change tool bit to drill size 1.00000mm)
M6 (Tool change.)
M0 (Temporary machine stop.)
M3 (Spindle on clockwise.)
G04 P1.00000
G00 Z1.50000

G0 X130.26000 Y-90.00000
G1 Z0.29167 F300.00000
G1 F600.00000
G2 X130.26000 Y-90.00000 Z-0.00000 I-0.10000 J0.00000
G2 X130.26000 Y-90.00000 Z-0.29167 I-0.10000 J0.00000
G2 X130.26000 Y-90.00000 Z-0.58333 I-0.10000 J0.00000
G2 X130.26000 Y-90.00000 Z-0.87500 I-0.10000 J0.00000
G2 X130.26000 Y-90.00000 Z-1.16667 I-0.10000 J0.00000
G2 X130.26000 Y-90.00000 Z-1.45833 I-0.10000 J0.00000
G2 X130.26000 Y-90.00000 Z-1.75000 I-0.10000 J0.00000
G2 X130.26000 Y-90.00000 I-0.10000 J0.00000
G1 Z1.50000 F300.00000

G0 X130.36000 Y-92.54000
G1 Z0.29167 F300.00000
G1 F600.00000
G2 X130.36000 Y-92.54000 Z-0.00000 I-0.20000 J0.00000
G2 X130.36000 Y-92.54000 Z-0.29167 I-0.20000 J0.00000
G2 X130.36000 Y-92.54000 Z-0.58333 I-0.20000 J0.00000
G2 X130.36000 Y-92.54000 Z-0.87500 I-0.20000 J0.00000
G2 X130.36000 Y-92.54000 Z-1.16667 I-0.20000 J0.00000
G2 X130.36000 Y-92.54000 Z-1.45833 I-0.20000 J0.00000
G2 X130.36000 Y-92.54000 Z-1.75000 I-0.20000 J0.00000
G2 X130.36000 Y-92.54000 I-0.20000 J0.00000
G1 Z1.50000 F300.00000

G0 X130.46000 Y-95.08000
G1 Z0.29167 F300.00000
G1 F600.00000
G2 X130.46000 Y-95.08000 Z-0.00000 I-0.30000 J0.00000
G2 X130.46000 Y-95.08000 Z-0.29167 I-0.30000 J0.00000
G2 X130.46000 Y-95.08000 Z-0.58333 I-0.30000 J0.00000
G2 X130.46000 Y-95.08000 Z-0.87500 I-0.30000 J0.00000
G2 X130.46000 Y-95.08000 Z-1.16667 I-0.30000 J0.00000
G2 X130.46000 Y-95.08000 Z-1.45833 I-0.30000 J0.00000
G2 X130.46000 Y-95.08000 Z-1.75000 I-0.30000 J0.00000
G2 X130.46000 Y-95.08000 I-0.30000 J0.00000
G1 Z1.50000 F300.00000

G0 X130.56000 Y-97.62000
G1 Z0.29167 F300.00000
G1 F600.00000
G2 X130.56000 Y-97.62000 Z-0.00000 I-0.40000 J0.00000
G2 X130.56000 Y-97.62000 Z-0.29167 I-0.40000 J0.00000
G2 X130.56000 Y-97.62000 Z-0.58333 I-0.40000 J0.00000
G2 X130.56000 Y-97.62000 Z-0.87500 I-0.40000 J0.00000
G2 X130.56000 Y-97.62000 Z-1.16667 I-0.40000 J0.00000
G2 X130.56000 Y-97.62000 Z-1.45833 I-0.40000 J0.00000
G2 X130.56000 Y-97.62000 Z-1.75000 I-0.40000 J0.00000
G2 X130.56000 Y-97.62000 I-0.40000 J0.00000
G1 Z1.50000 F300.00000

G0 X130.66000 Y-100.16000
G1 Z0.29167 F300.00000
G1 F600.00000
G2 X130.66000 Y-100.16000 Z-0.00000 I-0.50000 J0.00000
G2 X130.66000 Y-100.16000 Z-0.29167 I-0.50000 J0.00000
G2 X130.66000 Y-100.16000 Z-0.58333 I-0.50000 J0.00000
G2 X130.66000 Y-100.16000 Z-0.87500 I-0.50000 J0.00000
G2 X130.66000 Y-100.16000 Z-1.16667 I-0.50000 J0.00000
G2 X130.66000 Y-100.16000 Z-1.45833 I-0.50000 J0.00000
G2 X130.66000 Y-100.16000 Z-1.75000 I-0.50000 J0.00000
G2 X130.66000 Y-100.16000 I-0.50000 J0.00000
G1 Z1.50000 F300.00000

G00 Z10.000000 ( All done -- retract )

M5 (Spindle off.)
G04 P1.000000
M9 (Coolant off.)
M2 (Program end.)

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions testing/gerbv_example/milldrilldiatest_units/milldrilldiatest.drl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
M48
;DRILL file {KiCad 4.0.7+dfsg1-1~bpo9+1} date Mon Oct 15 16:46:01 2018
;FORMAT={-:-/ absolute / metric / decimal}
FMAT,2
METRIC,TZ
T1C0.200
T2C0.400
T3C0.600
T4C0.800
T5C1.000
T6C1.200
T7C1.400
T8C1.600
T9C1.800
T10C2.000
%
G90
G05
M71
T1
X120.Y-90.
T2
X120.Y-92.54
T3
X120.Y-95.08
T4
X120.Y-97.62
T5
X120.Y-100.16
T6
X130.16Y-90.
T7
X130.16Y-92.54
T8
X130.16Y-95.08
T9
X130.16Y-97.62
T10
X130.16Y-100.16
T0
M30
17 changes: 17 additions & 0 deletions testing/gerbv_example/milldrilldiatest_units/millproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
drill=milldrilldiatest.drl

metric=true
metricoutput=true
zchange=10.0000
zsafe=1.5000
drill-feed=100
drill-speed=10000
zdrill=-1.7500mm
cut-feed=600
cut-infeed=0.3
cut-speed=2000
cutter-diameter=2.0
zcut=-1.6500
min-milldrill-hole-diameter=1.2
milldrill-diameter=1.0mm
drills-available=0.4,0.6,0.8,1.0,1.2

0 comments on commit dba66d2

Please sign in to comment.