Skip to content

Commit 28625e3

Browse files
committed
[Fancy Stack-up][Fixed] KiCad 9 inner layer computation
Fixes #870
1 parent 0ddc114 commit 28625e3

5 files changed

Lines changed: 25 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3333
- Huge memory usage for panels (#842)
3434
- Panelize: vjustify wrong choices (were the same as hjustify) (#846)
3535
- THT Resistors: Problems when using the STEP version of the model (#856)
36-
- Fancy stackup: Limit the decimals of the copper weight to 2 (#864)
36+
- Fancy stackup:
37+
- Limit the decimals of the copper weight to 2 (#864)
38+
- Buried vias issues on KiCad 9 (#870)
39+
3740

3841
### Changed
3942
- Filtered KiBot warnings are informed in the debug output (See #817)

docs/source/Changelog.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ Fixed
6161
- Panelize: vjustify wrong choices (were the same as hjustify) (#846)
6262
- THT Resistors: Problems when using the STEP version of the model
6363
(#856)
64-
- Fancy stackup: Limit the decimals of the copper weight to 2 (#864)
64+
- Fancy stackup:
65+
66+
- Limit the decimals of the copper weight to 2 (#864)
67+
- Buried vias issues on KiCad 9 (#870)
6568

6669
Changed
6770
~~~~~~~

kibot/gs.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,14 +1119,18 @@ def inner_layer_index(id):
11191119

11201120
@staticmethod
11211121
def copper_layer_to_ordinal(n):
1122-
ordinal = pcbnew.CopperLayerToOrdinal(n)
1123-
# Adjust to the current PCB
1124-
if ordinal == pcbnew.CopperLayerToOrdinal(pcbnew.B_Cu):
1125-
ordinal = GS.board.GetCopperLayerCount()-1
1126-
return ordinal
1122+
if GS.ki9:
1123+
ordinal = pcbnew.CopperLayerToOrdinal(n)
1124+
# Adjust to the current PCB
1125+
if ordinal == pcbnew.CopperLayerToOrdinal(pcbnew.B_Cu):
1126+
ordinal = GS.board.GetCopperLayerCount()-1
1127+
return ordinal
1128+
# <= 8
1129+
return GS.board.GetCopperLayerCount()-1 if n == pcbnew.B_Cu else n
11271130

11281131
@staticmethod
11291132
def ordinal_to_copper_layer(n):
1133+
# Only for KiCad 9+
11301134
if n == GS.board.GetCopperLayerCount()-1:
11311135
return pcbnew.B_Cu
11321136
if n == 0:

kibot/misc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@
340340
W_DEFNOSTR = '(W172) '
341341
W_CONVPDF = '(W173) '
342342
W_MISSWRL = '(W174) '
343+
W_STACKUP = '(W175) '
343344
# Somehow arbitrary, the colors are real, but can be different
344345
PCB_MAT_COLORS = {'fr1': "937042", 'fr2': "949d70", 'fr3': "adacb4", 'fr4': "332B16", 'fr5': "6cc290"}
345346
PCB_FINISH_COLORS = {'hal': "8b898c", 'hasl': "8b898c", 'imag': "8b898c", 'enig': "cfb96e", 'enepig': "cfb96e",

kibot/pre_draw_fancy_stackup.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .layer import Layer
1414
from .optionable import Optionable
1515
from .macros import macros, document, pre_class # noqa: F401
16-
from .misc import VIATYPE_THROUGH, VIATYPE_BLIND_BURIED, VIATYPE_MICROVIA, W_NOVIAS
16+
from .misc import VIATYPE_THROUGH, VIATYPE_BLIND_BURIED, VIATYPE_MICROVIA, W_NOVIAS, W_STACKUP
1717
from . import log
1818
import pcbnew
1919
logger = log.get_logger()
@@ -146,6 +146,9 @@ def __init__(self):
146146
self.layer_type = ''
147147
self.gerber = ''
148148

149+
def __str__(self):
150+
return f"{self.layer} mat: {self.material} thick: {self.thickness} use: {self.layer_type} type: {self.type}"
151+
149152

150153
def draw_core(g, x, y, w, h, layer, offset, border_w=10000):
151154
y = y-int(h*0.5)+offset
@@ -647,16 +650,16 @@ def create_stackup_matrix(stackup, via_layer_pairs, draw_vias):
647650

648651

649652
def get_layer_number(stackup, number):
650-
copper_num = number
651-
if number == pcbnew.B_Cu:
652-
copper_num = GS.board.GetCopperLayerCount() - 1
653+
copper_num = GS.copper_layer_to_ordinal(number)
653654

654655
i = 0
655656
for n, layer in enumerate(stackup):
656657
if layer.type == 'copper':
657658
if i == copper_num:
658659
return n
659660
i += 1
661+
logger.warning(W_STACKUP+f"Wrong stack up? (layer id: {number} not found)")
662+
return n
660663

661664

662665
def update_drawing(ops, parent):

0 commit comments

Comments
 (0)