diff --git a/CHANGELOG.md b/CHANGELOG.md index f09c5503..4896ba71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `--dont-stop` command line option, to try to continue even on errors (#209) - PDF/SVG PCB Print: option to print all pages/single page (#236) - iBoM: Support for variants that change component fields (#242) -- Workaround for problems with DRC exclusions (See INTI-CMNB/KiAuto#26) +- Workaround for problems with DRC exclusions (See INTI-CMNB/KiAuto#26, #250) Global option: `drc_exclusions_workaround` KiCad bug [11562](https://gitlab.com/kicad/code/kicad/-/issues/11562) - Internal BoM: KiCad 6 text variables expansion in the fields (#247) diff --git a/kibot/gs.py b/kibot/gs.py index ef3c83f5..fe92f9a6 100644 --- a/kibot/gs.py +++ b/kibot/gs.py @@ -170,6 +170,18 @@ class GS(object): logger.debug("Current text variables: {}".format(GS.pro_variables)) return GS.pro_variables + @staticmethod + def read_pro(): + if GS.pro_file: + with open(GS.pro_file, 'rt') as f: + return f.read() + + @staticmethod + def write_pro(prj): + if GS.pro_file and prj: + with open(GS.pro_file, 'wt') as f: + f.write(prj) + @staticmethod def load_sch_title_block(): if GS.sch_title is not None: diff --git a/kibot/pre_fill_zones.py b/kibot/pre_fill_zones.py index 98cc8661..a4788bdf 100644 --- a/kibot/pre_fill_zones.py +++ b/kibot/pre_fill_zones.py @@ -24,4 +24,9 @@ class Fill_Zones(BasePreFlight): # noqa: F821 load_board() pcbnew.ZONE_FILLER(GS.board).Fill(GS.board.Zones()) GS.make_bkp(GS.pcb_file) + # KiCad likes to write the project every time we save the PCB + # But KiCad doesn't read the exclusions, so they get lost + # As a workaround we restore the project, there is no need to change it + prj = GS.read_pro() GS.board.Save(GS.pcb_file) + GS.write_pro(prj)