diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d1b3011..a8b3cba0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 components marked as *Do Not Populate*. This option applies to the case where no filter or variants are in use. Enabled by default. The `kicad_dnp_applied` option also disables it. + - `cross_using_kicad` global option to use KiCad to cross DNP components in + the schematic. Enabled by default. ### Fixed - Problems to detect the schematic name when the path to the config contained a diff --git a/README.md b/README.md index 7bcb3a89..1fd78f32 100644 --- a/README.md +++ b/README.md @@ -751,7 +751,8 @@ global: - `copper_thickness`: [number|string] Copper thickness in micrometers (1 Oz is 35 micrometers). KiCad 6: you should set this in the Board Setup -> Physical Stackup. - `cross_footprints_for_dnp`: [boolean=true] Draw a cross for excluded components in the `Fab` layer. - - `cross_no_body`: [boolean=false] Cross components even when they don't have a body. Only for KiCad 6. + - `cross_no_body`: [boolean=false] Cross components even when they don't have a body. Only for KiCad 6 and internal cross. + - `cross_using_kicad`: [boolean=true] When using KiCad 7+ let KiCad cross the components. - `csv_accept_no_ref`: [boolean=false] Accept aggregating CSV files without references (Experimental). - `date_format`: [string='%Y-%m-%d'] Format used for the day we started the script. Is also used for the PCB/SCH date formatting when `time_reformat` is enabled (default behavior). @@ -810,6 +811,9 @@ global: - `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. + - `kicad_dnp_applies_to_3D`: [boolean=true] The KiCad v7 PCB flag *Do Not Populate* is applied to our fitted flag for 3D models, + even when no filter/variant is specified. Disabling `kicad_dnp_applied` also disables + this flag. - `out_dir`: [string=''] Base output dir, same as command line `--out-dir`. - `output`: [string='%f-%i%I%v.%x'] Default pattern for output file names. Affected by global options. - `pcb_finish`: [string='HAL'] Finishing used to protect pads. Currently used for documentation and to choose default colors. diff --git a/kibot/globals.py b/kibot/globals.py index 70869332..8dd5a8cf 100644 --- a/kibot/globals.py +++ b/kibot/globals.py @@ -137,7 +137,9 @@ class Globals(FiltersOptions): self.cross_footprints_for_dnp = True """ Draw a cross for excluded components in the `Fab` layer """ self.cross_no_body = False - """ Cross components even when they don't have a body. Only for KiCad 6 """ + """ Cross components even when they don't have a body. Only for KiCad 6 and internal cross """ + self.cross_using_kicad = True + """ When using KiCad 7+ let KiCad cross the components """ self.csv_accept_no_ref = False """ Accept aggregating CSV files without references (Experimental) """ self.date_format = '%Y-%m-%d' diff --git a/kibot/gs.py b/kibot/gs.py index 28e32b29..7d03837e 100644 --- a/kibot/gs.py +++ b/kibot/gs.py @@ -169,6 +169,7 @@ class GS(object): global_erc_grid = None global_kicad_dnp_applied = None global_kicad_dnp_applies_to_3D = None + global_cross_using_kicad = None @staticmethod def set_sch(name): diff --git a/kibot/kicad/v6_sch.py b/kibot/kicad/v6_sch.py index 10c758e2..fcb19951 100644 --- a/kibot/kicad/v6_sch.py +++ b/kibot/kicad/v6_sch.py @@ -1106,9 +1106,15 @@ class SchematicComponentV6(SchematicComponent): def write(self, cross=False): lib_id = self.lib_id is_crossed = not(self.fitted or not self.included) + native_cross = GS.ki7 and GS.global_cross_using_kicad + dnp = False if native_cross else self.kicad_dnp if cross and (self.lib or self.local_name) and is_crossed: - # Use an alternative name - lib_id = CROSSED_LIB+':'+(self.local_name if self.local_name else self.name) + if native_cross: + # Just inform KiCad we want to make it DNP + dnp = True + else: + # Use an alternative name + lib_id = CROSSED_LIB+':'+(self.local_name if self.local_name else self.name) data = [_symbol('lib_id', [lib_id]), _symbol('at', [self.x, self.y, self.ang])] if self.mirror: @@ -1120,8 +1126,8 @@ class SchematicComponentV6(SchematicComponent): data.append(Sep()) data.append(_symbol('in_bom', [Symbol(NO_YES[self.in_bom])])) data.append(_symbol('on_board', [Symbol(NO_YES[self.on_board])])) - if self.kicad_dnp is not None: - data.append(_symbol('dnp', [Symbol(NO_YES[self.kicad_dnp])])) + if dnp is not None: + data.append(_symbol('dnp', [Symbol(NO_YES[dnp])])) if self.fields_autoplaced: data.append(_symbol('fields_autoplaced')) data.append(Sep()) @@ -1704,6 +1710,9 @@ class SchematicV6(Schematic): return [Sep(), Sep(), _symbol('title_block', [Sep()]+data)] def write_lib_symbols(self, cross=False): + if GS.ki7 and GS.global_cross_using_kicad: + # KiCad 7 can cross it by itself + cross = False data = [Sep()] for s in self.lib_symbols: data.extend([s.write(), Sep()]) diff --git a/tests/reference/7_0_0/test_v5-schematic_(no_L).pdf b/tests/reference/7_0_0/test_v5-schematic_(no_L).pdf index c2010f3a..292b813b 100644 Binary files a/tests/reference/7_0_0/test_v5-schematic_(no_L).pdf and b/tests/reference/7_0_0/test_v5-schematic_(no_L).pdf differ diff --git a/tests/reference/7_0_0/test_v5-schematic_(no_L).svg b/tests/reference/7_0_0/test_v5-schematic_(no_L).svg index 35a5d6b0..204170e0 100644 --- a/tests/reference/7_0_0/test_v5-schematic_(no_L).svg +++ b/tests/reference/7_0_0/test_v5-schematic_(no_L).svg @@ -7,7 +7,7 @@ xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="297.0022mm" height="210.0072mm" viewBox="0.0000 0.0000 297.0022 210.0072"> -SVG Image created as test_v5.svg date 2023/03/08 07:51:39 +SVG Image created as test_v5.svg date 2023/03/08 13:54:19 Image generated by Eeschema-SVG - - - - - - - - - - - + + + + + + + - - + + + + + + + + diff --git a/tests/reference/7_0_0/test_v5_wks-schematic_(no_L).pdf b/tests/reference/7_0_0/test_v5_wks-schematic_(no_L).pdf index 235e4b3a..0b791ad2 100644 Binary files a/tests/reference/7_0_0/test_v5_wks-schematic_(no_L).pdf and b/tests/reference/7_0_0/test_v5_wks-schematic_(no_L).pdf differ diff --git a/tests/test_plot/test_print_sch.py b/tests/test_plot/test_print_sch.py index 77441c11..326ab6a5 100644 --- a/tests/test_plot/test_print_sch.py +++ b/tests/test_plot/test_print_sch.py @@ -119,8 +119,11 @@ def check_l1(ctx): l1 = next(c for c in comps if c.ref == 'L1') assert l1 logging.debug('Found L1') - lib_name = 'n' if context.ki5() else 'kibot_crossed' - assert l1.lib == lib_name + if context.ki7(): + assert l1.kicad_dnp + else: + lib_name = 'n' if context.ki5() else 'kibot_crossed' + assert l1.lib == lib_name logging.debug('L1 is crossed') ctx.clean_up()