diff --git a/CHANGELOG.md b/CHANGELOG.md index efb1d8b1..37fc59eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - General: - OS environment expansion in ${VAR} - Now outputs can request to be added to one or more groups (#435) + - PCB text variables cached in the PCB are now reset when the config + uses `set_text_variables`. This is a complex dilemma of KiCad 6/7 + policy implementation. See + [KiCad issue 14360](https://gitlab.com/kicad/code/kicad/-/issues/14360). + (#441) - Command line: - `--list-variants` List all available variants (See #434) - `--only-names` to make `--list` list only output names @@ -23,6 +28,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `field_temp_coef` Name/s of the field/s used for the temperature coefficient - `field_power` Name/s of the field/s used for the power raiting + - `invalidate_pcb_text_cache` controls if we reset the text variables cached + in the PCB file. - Filters: - New `value_split` to extract information from the Value field and put it in separated fields. I.e. tolerance, voltage, etc. diff --git a/README.md b/README.md index a4e90a07..7fe129d4 100644 --- a/README.md +++ b/README.md @@ -838,6 +838,10 @@ global: - `hide_excluded`: [boolean=false] Default value for the `hide_excluded` option of various PCB outputs. - `impedance_controlled`: [boolean=false] The PCB needs specific dielectric characteristics. KiCad 6: you should set this in the Board Setup -> Physical Stackup. + - `invalidate_pcb_text_cache`: [string='auto'] [auto,yes,no] Remove any cached text variable in the PCB. This is needed in order to force a text + variables update when using `set_text_variables`. You might want to disable it when applying some + changes to the PCB and create a new copy to send to somebody without changing the cached values. + The `auto` value will remove the cached values only when using `set_text_variables`. - `kiauto_time_out_scale`: [number=0.0] Time-out multiplier for KiAuto operations. - `kiauto_wait_start`: [number=0] Time to wait for KiCad in KiAuto operations. - `kicad_dnp_applied`: [boolean=true] The KiCad v7 PCB flag *Do Not Populate* is applied to our fitted flag before running any filter. diff --git a/kibot/globals.py b/kibot/globals.py index cda654a1..5e65bca8 100644 --- a/kibot/globals.py +++ b/kibot/globals.py @@ -338,6 +338,11 @@ class Globals(FiltersOptions): """ [string|list(string)] Name/s of the field/s used for the power raiting. Used for the value split filter. The default is ['power', 'pow'] """ + self.invalidate_pcb_text_cache = 'auto' + """ [auto,yes,no] Remove any cached text variable in the PCB. This is needed in order to force a text + variables update when using `set_text_variables`. You might want to disable it when applying some + changes to the PCB and create a new copy to send to somebody without changing the cached values. + The `auto` value will remove the cached values only when using `set_text_variables` """ self.set_doc('filters', " [list(dict)] KiBot warnings to be ignored ") self._filter_what = 'KiBot warnings' self.filters = FilterOptionsKiBot diff --git a/kibot/gs.py b/kibot/gs.py index b823b1f9..6c1b08ed 100644 --- a/kibot/gs.py +++ b/kibot/gs.py @@ -152,6 +152,7 @@ class GS(object): global_field_voltage = None global_hide_excluded = None global_impedance_controlled = None + global_invalidate_pcb_text_cache = None global_kiauto_time_out_scale = None global_kiauto_wait_start = None # This value will overwrite GS.def_global_output if defined diff --git a/kibot/kiplot.py b/kibot/kiplot.py index eebfd9f2..ea62f986 100644 --- a/kibot/kiplot.py +++ b/kibot/kiplot.py @@ -212,6 +212,10 @@ def load_board(pcb_file=None, forced=False): try: with hide_stderr(): board = pcbnew.LoadBoard(pcb_file) + if GS.global_invalidate_pcb_text_cache == 'yes' and GS.ki6: + logger.debug('Current PCB text variables cache: {}'.format(board.GetProperties().items())) + logger.debug('Removing cached text variables') + board.SetProperties(pcbnew.MAP_STRING_STRING()) if BasePreFlight.get_option('check_zone_fills'): GS.fill_zones(board) if GS.global_units and GS.ki6: diff --git a/kibot/pre_set_text_variables.py b/kibot/pre_set_text_variables.py index 6f4a1418..24129f69 100644 --- a/kibot/pre_set_text_variables.py +++ b/kibot/pre_set_text_variables.py @@ -165,3 +165,7 @@ class Set_Text_Variables(BasePreFlight): # noqa: F821 if GS.board: # Force a project and PCB reload GS.reload_project(pro_name) + # Check if we need to force a PCB text variables reset + if GS.global_invalidate_pcb_text_cache == 'auto': + logger.debug('Forcing PCB text variables reset') + GS.global_invalidate_pcb_text_cache = 'yes'