[DRC] Another workaround for KiCad lack of exclusions support in Python

- Saving the project can remove them, so `fill_zones` removed them

Fixes #250
This commit is contained in:
Salvador E. Tropea 2022-08-17 13:33:57 -03:00
parent 8fa4f985d3
commit 0180136fd6
3 changed files with 18 additions and 1 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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)