KiCad v6: Added support for the new "modules" name ("footprints")

- No alias provided, as usual
This commit is contained in:
Diego Capusotto 2021-12-17 12:46:40 -03:00
parent 14e0a90dce
commit 69c874fdbd
5 changed files with 29 additions and 13 deletions

View File

@ -149,6 +149,22 @@ class GS(object):
return title_block.GetComment3()
return title_block.GetComment4()
@staticmethod
def get_modules():
if GS.kicad_version_n >= KICAD_VERSION_5_99: # pragma: no cover (Ki6)
return GS.board.GetFootprints()
return GS.board.GetModules()
@staticmethod
def get_modules_board(board):
if GS.kicad_version_n >= KICAD_VERSION_5_99: # pragma: no cover (Ki6)
return board.GetFootprints()
return board.GetModules()
@staticmethod
def ki6():
return GS.kicad_version_n >= KICAD_VERSION_5_99
@staticmethod
def load_pcb_title_block():
if GS.pcb_title is not None:

View File

@ -267,7 +267,7 @@ def get_board_comps_data(comps):
return
load_board()
comps_hash = {c.ref: c for c in comps}
for m in GS.board.GetModules():
for m in GS.get_modules():
ref = m.GetReference()
if ref not in comps_hash:
logger.warning(W_PCBNOSCH + '`{}` component in board, but not in schematic'.format(ref))

View File

@ -218,7 +218,7 @@ class VariantOptions(BaseOptions):
bfab = board.GetLayerID('B.Fab')
extra_ffab_lines = []
extra_bfab_lines = []
for m in board.GetModules():
for m in GS.get_modules_board(board):
ref = m.GetReference()
# Rectangle containing the drawings, no text
frect = Rect()
@ -251,7 +251,7 @@ class VariantOptions(BaseOptions):
if comps_hash is None:
return
# Undo the drawings
for m in board.GetModules():
for m in GS.get_modules_board(board):
ref = m.GetReference()
c = comps_hash.get(ref, None)
if c and c.included and not c.fitted:
@ -281,7 +281,7 @@ class VariantOptions(BaseOptions):
rescue = board.GetLayerID('Rescue')
fmask = board.GetLayerID('F.Mask')
bmask = board.GetLayerID('B.Mask')
for m in board.GetModules():
for m in GS.get_modules_board(board):
ref = m.GetReference()
c = comps_hash.get(ref, None)
if c and c.included and not c.fitted:
@ -319,7 +319,7 @@ class VariantOptions(BaseOptions):
def restore_paste_and_glue(self, board, comps_hash):
if comps_hash is None:
return
for m in board.GetModules():
for m in GS.get_modules_board(board):
ref = m.GetReference()
c = comps_hash.get(ref, None)
if c and c.included and not c.fitted:
@ -343,7 +343,7 @@ class VariantOptions(BaseOptions):
old_ffab = []
old_bfab = []
rescue = board.GetLayerID('Rescue')
for m in board.GetModules():
for m in GS.get_modules_board(board):
ref = m.GetReference()
c = comps_hash.get(ref, None)
if not c.included:

View File

@ -52,7 +52,7 @@ class Base3DOptions(VariantOptions):
def undo_3d_models_rename(self):
""" Restores the file name for any renamed 3D module """
for m in GS.board.GetModules():
for m in GS.get_modules():
# Get the model references
models = m.Models()
models_l = []
@ -107,7 +107,7 @@ class Base3DOptions(VariantOptions):
downloaded = set()
self.undo_3d_models = {}
# Look for all the footprints
for m in GS.board.GetModules():
for m in GS.get_modules():
ref = m.GetReference()
# Extract the models (the iterator returns copies)
models = m.Models()
@ -158,7 +158,7 @@ class Base3DOptions(VariantOptions):
KiConf.init(GS.pcb_file)
models = set()
# Look for all the footprints
for m in GS.board.GetModules():
for m in GS.get_modules():
# Look for all the 3D models for this footprint
for m3d in m.Models():
full_name = KiConf.expand_env(m3d.m_Filename)
@ -184,7 +184,7 @@ class Base3DOptions(VariantOptions):
if GS.debug_level > 3:
logger.debug("{} 3D models that aren't for this variant".format('Enable' if enable else 'Disable'))
len_disable = len(DISABLE_TEXT)
for m in GS.board.GetModules():
for m in GS.get_modules():
if GS.debug_level > 3:
logger.debug("Processing module " + m.GetReference())
# Look for text objects
@ -235,7 +235,7 @@ class Base3DOptions(VariantOptions):
self.apply_variant_aspect()
# Remove the 3D models for not fitted components
rem_models = []
for m in GS.board.GetModules():
for m in GS.get_modules():
ref = m.GetReference()
c = comps_hash.get(ref, None)
if c:
@ -257,7 +257,7 @@ class Base3DOptions(VariantOptions):
fname = self.save_board(dir)
self.undo_3d_models_rename()
# Undo the removing
for m in GS.board.GetModules():
for m in GS.get_modules():
ref = m.GetReference()
c = comps_hash.get(ref, None)
if c and c.included and not c.fitted:

View File

@ -232,7 +232,7 @@ class PositionOptions(VariantOptions):
if self.use_aux_axis_as_origin:
(x_origin, y_origin) = GS.board.GetAuxOrigin()
logger.debug('Using auxiliar origin: x={} y={}'.format(x_origin, y_origin))
for m in sorted(GS.board.GetModules(), key=lambda c: _ref_key(c.GetReference())):
for m in sorted(GS.get_modules(), key=lambda c: _ref_key(c.GetReference())):
ref = m.GetReference()
logger.debug('P&P ref: {}'.format(ref))
value = None