From fec009171223ddbf868c16c54015eaf12d0b07aa Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Fri, 16 Oct 2020 17:04:37 -0300 Subject: [PATCH] Added support for KiCad 6 to drill outputs. I wonder why KiCad 6 doesn't provide a compatibility function for GetAuxOrigin. The project seems to be trying to reduce the ammount of code (removing old code) at the cost of breaking every existing plug-in. --- kibot/out_any_drill.py | 10 +- tests/board_samples/kicad_6/3Rs.kicad_pcb | 204 ++++++++++++++++++++++ tests/test_plot/test_drill.py | 4 +- 3 files changed, 215 insertions(+), 3 deletions(-) create mode 100644 tests/board_samples/kicad_6/3Rs.kicad_pcb diff --git a/kibot/out_any_drill.py b/kibot/out_any_drill.py index d74451db..12d1ad1a 100644 --- a/kibot/out_any_drill.py +++ b/kibot/out_any_drill.py @@ -8,6 +8,7 @@ from pcbnew import (PLOT_FORMAT_HPGL, PLOT_FORMAT_POST, PLOT_FORMAT_GERBER, PLOT PLOT_FORMAT_PDF, wxPoint) from .optionable import (Optionable, BaseOptions) from .gs import GS +from .misc import KICAD_VERSION_5_99 from .macros import macros, document # noqa: F401 from . import log @@ -35,6 +36,13 @@ class DrillReport(Optionable): self._unkown_is_error = True +def get_aux_origin(board): + if GS.kicad_version_n >= KICAD_VERSION_5_99: + settings = board.GetDesignSettings() + return settings.m_AuxOrigin + return board.GetAuxOrigin() + + class AnyDrill(BaseOptions): def __init__(self): # Options @@ -82,7 +90,7 @@ class AnyDrill(BaseOptions): def run(self, output_dir, board): # dialog_gendrill.cpp:357 if self.use_aux_axis_as_origin: - offset = board.GetAuxOrigin() + offset = get_aux_origin(board) else: offset = wxPoint(0, 0) drill_writer, ext = self._configure_writer(board, offset) diff --git a/tests/board_samples/kicad_6/3Rs.kicad_pcb b/tests/board_samples/kicad_6/3Rs.kicad_pcb new file mode 100644 index 00000000..c53ca379 --- /dev/null +++ b/tests/board_samples/kicad_6/3Rs.kicad_pcb @@ -0,0 +1,204 @@ +(kicad_pcb (version 20201002) (generator pcbnew) + + (general + (thickness 1.6) + ) + + (paper "A4") + (layers + (0 "F.Cu" signal) + (31 "B.Cu" signal) + (32 "B.Adhes" user "B.Adhesive") + (33 "F.Adhes" user "F.Adhesive") + (34 "B.Paste" user) + (35 "F.Paste" user) + (36 "B.SilkS" user "B.Silkscreen") + (37 "F.SilkS" user "F.Silkscreen") + (38 "B.Mask" user) + (39 "F.Mask" user) + (40 "Dwgs.User" user "User.Drawings") + (41 "Cmts.User" user "User.Comments") + (42 "Eco1.User" user "User.Eco1") + (43 "Eco2.User" user "User.Eco2") + (44 "Edge.Cuts" user) + (45 "Margin" user) + (46 "B.CrtYd" user "B.Courtyard") + (47 "F.CrtYd" user "F.Courtyard") + (48 "B.Fab" user) + (49 "F.Fab" user) + ) + + (setup + (pcbplotparams + (layerselection 0x00010fc_ffffffff) + (disableapertmacros false) + (usegerberextensions false) + (usegerberattributes false) + (usegerberadvancedattributes false) + (creategerberjobfile false) + (svguseinch false) + (svgprecision 6) + (excludeedgelayer true) + (plotframeref false) + (viasonmask false) + (mode 1) + (useauxorigin false) + (hpglpennumber 1) + (hpglpenspeed 20) + (hpglpendiameter 15.000000) + (psnegative false) + (psa4output false) + (plotreference true) + (plotvalue true) + (plotinvisibletext false) + (sketchpadsonfab false) + (subtractmaskfromsilk false) + (outputformat 1) + (mirror false) + (drillshape 1) + (scaleselection 1) + (outputdirectory "") + ) + ) + + + (net 0 "") + + (module "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" (layer "F.Cu") (tedit 5B36C52B) (tstamp 00000000-0000-0000-0000-00005ea76d80) + (at 105 35 90) + (descr "Resistor SMD 0805 (2012 Metric), square (rectangular) end terminal, IPC_7351 nominal with elongated pad for handsoldering. (Body size source: https://docs.google.com/spreadsheets/d/1BsfQQcO9C6DZCsRaXUlFlo91Tg2WpOkGARC1WS5S8t0/edit?usp=sharing), generated with kicad-footprint-generator") + (tags "resistor handsolder") + (attr smd) + (fp_text reference "R1" (at 0 -1.65 90) (layer "F.SilkS") + (effects (font (size 1 1) (thickness 0.15))) + (tstamp 7accab11-60c9-461f-ba53-a70ef610ef19) + ) + (fp_text value "R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" (at 0 1.65 90) (layer "F.Fab") + (effects (font (size 1 1) (thickness 0.15))) + (tstamp bfb2ae84-71ae-497d-817c-7afccc6c3d10) + ) + (fp_text user "100" (at 0 0 90) (layer "F.Fab") + (effects (font (size 0.5 0.5) (thickness 0.08))) + (tstamp 3e391892-edcb-4f5c-8776-b26e20029ef6) + ) + (fp_line (start -0.261252 0.71) (end 0.261252 0.71) (layer "F.SilkS") (width 0.12) (tstamp 3011df62-c0d7-4b9c-b1f9-a9984bc57a14)) + (fp_line (start -0.261252 -0.71) (end 0.261252 -0.71) (layer "F.SilkS") (width 0.12) (tstamp f46daced-b9c6-4d64-a28c-6afb7e2c3065)) + (fp_line (start 1.85 0.95) (end -1.85 0.95) (layer "F.CrtYd") (width 0.05) (tstamp 0217af6d-5725-4e07-b2d1-e6f17cf8c636)) + (fp_line (start -1.85 0.95) (end -1.85 -0.95) (layer "F.CrtYd") (width 0.05) (tstamp 3e9cce14-3415-452e-bdc2-0227361387b6)) + (fp_line (start -1.85 -0.95) (end 1.85 -0.95) (layer "F.CrtYd") (width 0.05) (tstamp 4b0e6714-7a3d-4a9c-8633-296acc4bc88d)) + (fp_line (start 1.85 -0.95) (end 1.85 0.95) (layer "F.CrtYd") (width 0.05) (tstamp 7cd569c7-a497-43f6-8a18-c63a614332b7)) + (fp_line (start 1 0.6) (end -1 0.6) (layer "F.Fab") (width 0.1) (tstamp 2702b853-e972-47a7-ad9a-9798d1c0efbd)) + (fp_line (start -1 -0.6) (end 1 -0.6) (layer "F.Fab") (width 0.1) (tstamp 2ddef00a-9f12-4837-8569-6063e471cad8)) + (fp_line (start 1 -0.6) (end 1 0.6) (layer "F.Fab") (width 0.1) (tstamp 8023ef0f-6945-46ec-a981-7b131d3d0abe)) + (fp_line (start -1 0.6) (end -1 -0.6) (layer "F.Fab") (width 0.1) (tstamp 85bb78b4-3e17-45b4-b116-981f52407a88)) + (pad "1" smd roundrect (at -1.025 0 90) (size 1.15 1.4) (layers "F.Cu" "F.Paste" "F.Mask") (roundrect_rratio 0.217391) (tstamp 9b6853f1-1f2b-46bb-86bb-c96ab23e5fa9)) + (pad "2" smd roundrect (at 1.025 0 90) (size 1.15 1.4) (layers "F.Cu" "F.Paste" "F.Mask") (roundrect_rratio 0.217391) (tstamp 082ba767-9485-4883-93b1-46cd6b032d47)) + (model "${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.wrl" + (offset (xyz 0 0 0)) + (scale (xyz 1 1 1)) + (rotate (xyz 0 0 0)) + ) + ) + + (module "Resistor_THT:R_Box_L13.0mm_W4.0mm_P9.00mm" (layer "F.Cu") (tedit 5AE5139B) (tstamp 00000000-0000-0000-0000-00005ea76ec0) + (at 110 45) + (descr "Resistor, Box series, Radial, pin pitch=9.00mm, 2W, length*width=13.0*4.0mm^2, http://www.produktinfo.conrad.com/datenblaetter/425000-449999/443860-da-01-de-METALLBAND_WIDERSTAND_0_1_OHM_5W_5Pr.pdf") + (tags "Resistor Box series Radial pin pitch 9.00mm 2W length 13.0mm width 4.0mm") + (attr through_hole) + (fp_text reference "R3" (at 4.5 -3.25) (layer "F.SilkS") + (effects (font (size 1 1) (thickness 0.15))) + (tstamp 60ea5e3e-dd18-4da5-b8f0-939cb41d6498) + ) + (fp_text value "R_Box_L13.0mm_W4.0mm_P9.00mm" (at 4.5 3.25) (layer "F.Fab") + (effects (font (size 1 1) (thickness 0.15))) + (tstamp 3def6d7e-7290-44d2-8ed9-c2e5c43626ce) + ) + (fp_text user "300" (at 4.5 0) (layer "F.Fab") + (effects (font (size 1 1) (thickness 0.15))) + (tstamp 27407789-cdfc-4f8a-8ac7-06bdef979f56) + ) + (fp_line (start -2.12 -2.12) (end -2.12 2.12) (layer "F.SilkS") (width 0.12) (tstamp 7af4e766-b871-48ce-8b98-48f12ab55700)) + (fp_line (start 11.12 -2.12) (end 11.12 2.12) (layer "F.SilkS") (width 0.12) (tstamp bff197df-2e9d-4e5b-b02a-6d1d875c548e)) + (fp_line (start -2.12 2.12) (end 11.12 2.12) (layer "F.SilkS") (width 0.12) (tstamp cf4e44be-ae4e-40a9-ad68-f03d79dcb1dd)) + (fp_line (start -2.12 -2.12) (end 11.12 -2.12) (layer "F.SilkS") (width 0.12) (tstamp f4411b38-872b-4492-b9f6-a161361afc62)) + (fp_line (start 11.25 -2.25) (end -2.25 -2.25) (layer "F.CrtYd") (width 0.05) (tstamp 5e6c289d-b3c4-4bbb-80aa-eb9526a12989)) + (fp_line (start 11.25 2.25) (end 11.25 -2.25) (layer "F.CrtYd") (width 0.05) (tstamp 6e5e110d-b885-4f13-9af0-7002489251f2)) + (fp_line (start -2.25 -2.25) (end -2.25 2.25) (layer "F.CrtYd") (width 0.05) (tstamp 77564e42-6b2c-411a-a64c-f03943640b57)) + (fp_line (start -2.25 2.25) (end 11.25 2.25) (layer "F.CrtYd") (width 0.05) (tstamp ca93b3d8-521f-49e8-81e9-b797eabca533)) + (fp_line (start -2 2) (end 11 2) (layer "F.Fab") (width 0.1) (tstamp 69b2f250-7e3c-4177-a6a5-11798c1789fe)) + (fp_line (start -2 -2) (end -2 2) (layer "F.Fab") (width 0.1) (tstamp bab10405-2df6-4f09-a546-81486a8098ef)) + (fp_line (start 11 2) (end 11 -2) (layer "F.Fab") (width 0.1) (tstamp c88e7db9-6e27-4690-a360-aa8a64ff13e1)) + (fp_line (start 11 -2) (end -2 -2) (layer "F.Fab") (width 0.1) (tstamp dcbc4cda-7fe2-47d5-b1dc-59b7e2a8301a)) + (pad "1" thru_hole circle (at 0 0) (size 2 2) (drill 1) (layers *.Cu *.Mask) (tstamp 785912b7-60c1-43ec-9811-4a74538adb8a)) + (pad "2" thru_hole circle (at 9 0) (size 2 2) (drill 1) (layers *.Cu *.Mask) (tstamp d69c2026-913a-4a9c-866d-4df3d8ce63a8)) + (model "${KISYS3DMOD}/Resistor_THT.3dshapes/R_Box_L13.0mm_W4.0mm_P9.00mm.wrl" + (offset (xyz 0 0 0)) + (scale (xyz 1 1 1)) + (rotate (xyz 0 0 0)) + ) + ) + + (module "MountingHole:MountingHole_2.1mm" (layer "F.Cu") (tedit 5B924765) (tstamp 00000000-0000-0000-0000-00005ebe1aa4) + (at 120 29) + (descr "Mounting Hole 2.1mm, no annular") + (tags "mounting hole 2.1mm no annular") + (attr exclude_from_pos_files exclude_from_bom) + (fp_text reference "REF**" (at 0 -3.2) (layer "F.SilkS") + (effects (font (size 1 1) (thickness 0.15))) + (tstamp 1d2988d6-294f-4e93-b979-f438ff3544cc) + ) + (fp_text value "MountingHole_2.1mm" (at 0 3.2) (layer "F.Fab") + (effects (font (size 1 1) (thickness 0.15))) + (tstamp e014c3c2-85c0-400c-8ee1-749eca4c0d34) + ) + (fp_text user "${REFERENCE}" (at 0.3 0) (layer "F.Fab") + (effects (font (size 1 1) (thickness 0.15))) + (tstamp c994ca02-fbbf-4c56-9a36-6854a0a43ff0) + ) + (fp_circle (center 0 0) (end 2.1 0) (layer "Cmts.User") (width 0.15) (tstamp 7387fc61-ddba-40f1-bd9e-b6df68988ed3)) + (fp_circle (center 0 0) (end 2.35 0) (layer "F.CrtYd") (width 0.05) (tstamp 0d6b9c1e-4afb-499a-a533-00e027146f71)) + (pad "" np_thru_hole circle (at 0 0) (size 2.1 2.1) (drill 2.1) (layers *.Cu *.Mask) (tstamp ceb4799f-93d5-4176-a733-69d970a274b6)) + ) + + (module "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" (layer "B.Cu") (tedit 5B36C52B) (tstamp 00000000-0000-0000-0000-00005ea76de9) + (at 110 35 -90) + (descr "Resistor SMD 0805 (2012 Metric), square (rectangular) end terminal, IPC_7351 nominal with elongated pad for handsoldering. (Body size source: https://docs.google.com/spreadsheets/d/1BsfQQcO9C6DZCsRaXUlFlo91Tg2WpOkGARC1WS5S8t0/edit?usp=sharing), generated with kicad-footprint-generator") + (tags "resistor handsolder") + (attr smd) + (fp_text reference "R2" (at 0 1.65 -90) (layer "B.SilkS") + (effects (font (size 1 1) (thickness 0.15)) (justify mirror)) + (tstamp e71fc067-1e15-464b-a67c-ed53b03d94de) + ) + (fp_text value "R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" (at 0 -1.65 -90) (layer "B.Fab") + (effects (font (size 1 1) (thickness 0.15)) (justify mirror)) + (tstamp 47b7ed7b-6581-4ac7-a0c2-91351ff83e2e) + ) + (fp_text user "150" (at 0 0 -90) (layer "B.Fab") + (effects (font (size 0.5 0.5) (thickness 0.08)) (justify mirror)) + (tstamp c62bf5bc-d850-4481-a9b8-3934e9ff0e51) + ) + (fp_line (start -0.261252 -0.71) (end 0.261252 -0.71) (layer "B.SilkS") (width 0.12) (tstamp f3ca6d98-c2d2-499c-a2b3-2b3e369f9988)) + (fp_line (start -0.261252 0.71) (end 0.261252 0.71) (layer "B.SilkS") (width 0.12) (tstamp f9e5a22a-6646-4709-b9b7-9673f6fcc184)) + (fp_line (start 1.85 0.95) (end 1.85 -0.95) (layer "B.CrtYd") (width 0.05) (tstamp 067cc84e-2712-40e8-a493-07e950859342)) + (fp_line (start 1.85 -0.95) (end -1.85 -0.95) (layer "B.CrtYd") (width 0.05) (tstamp 35b98d65-bd80-4ef9-8e78-54ec2fd1d85a)) + (fp_line (start -1.85 0.95) (end 1.85 0.95) (layer "B.CrtYd") (width 0.05) (tstamp c2821538-1c13-4611-9dba-ef30a5f812b7)) + (fp_line (start -1.85 -0.95) (end -1.85 0.95) (layer "B.CrtYd") (width 0.05) (tstamp eb39ded6-0c38-4927-9aa9-43dba7d17210)) + (fp_line (start 1 0.6) (end 1 -0.6) (layer "B.Fab") (width 0.1) (tstamp 2715ac95-ae1c-47bd-8b6a-bcf194b9cd8d)) + (fp_line (start 1 -0.6) (end -1 -0.6) (layer "B.Fab") (width 0.1) (tstamp 56f71ae4-54d4-4aea-911f-bd9df256d954)) + (fp_line (start -1 -0.6) (end -1 0.6) (layer "B.Fab") (width 0.1) (tstamp 600a7f13-2d22-43ba-84c0-98c3577b6a77)) + (fp_line (start -1 0.6) (end 1 0.6) (layer "B.Fab") (width 0.1) (tstamp 7c8ec9db-6194-410f-91ef-e468f5bdb544)) + (pad "1" smd roundrect (at -1.025 0 270) (size 1.15 1.4) (layers "B.Cu" "B.Paste" "B.Mask") (roundrect_rratio 0.217391) (tstamp d736e075-184f-4366-96db-afeb06451de8)) + (pad "2" smd roundrect (at 1.025 0 270) (size 1.15 1.4) (layers "B.Cu" "B.Paste" "B.Mask") (roundrect_rratio 0.217391) (tstamp 385f301d-d00a-47c6-9ff4-fd5305d883b6)) + (model "${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.wrl" + (offset (xyz 0 0 0)) + (scale (xyz 1 1 1)) + (rotate (xyz 0 0 0)) + ) + ) + + (gr_line (start 100 25) (end 100 50) (layer "Edge.Cuts") (width 0.05) (tstamp 00000000-0000-0000-0000-00005ea7192f)) + (gr_line (start 125 25) (end 125 50) (layer "Edge.Cuts") (width 0.05) (tstamp 00000000-0000-0000-0000-00005ea76efc)) + (gr_line (start 100 25) (end 125 25) (layer "Edge.Cuts") (width 0.05) (tstamp 00000000-0000-0000-0000-00005ea76f1d)) + (gr_line (start 100 50) (end 125 50) (layer "Edge.Cuts") (width 0.05) (tstamp eb88665f-f4a5-4024-9e6d-ee323df0995d)) + +) diff --git a/tests/test_plot/test_drill.py b/tests/test_plot/test_drill.py index 3af31e1b..3d673dcf 100644 --- a/tests/test_plot/test_drill.py +++ b/tests/test_plot/test_drill.py @@ -63,8 +63,8 @@ def do_3Rs(conf, dir, modern): def test_drill_3Rs(): - do_3Rs('drill', 'Drill_3Rs', True) + do_3Rs('drill', 'test_drill_3Rs', True) def test_drill_legacy_3Rs(): - do_3Rs('drill_legacy', 'DrillLegacy_3Rs', False) + do_3Rs('drill_legacy', 'test_drill_legacy_3Rs', False)