[QR_Lib][Fixed] Problems when moving the footprint to the bottom.

- The updated drawings always used the top layer

Fixes #271
This commit is contained in:
Salvador E. Tropea 2022-09-01 10:29:28 -03:00
parent 75f79b1a72
commit 61bee6e9cc
2 changed files with 17 additions and 1 deletions

View File

@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Internal Netlist generation (i.e. iBoM with variants): problems withg
components that doesn't specify a library. (See #242)
- Problems when setting a text variable to an empty string. (#268)
- QR lib update: Problems when moving the footprint to the bottom. (#271)
### Changed
- The order in which main sections are parsed is now fixed.

View File

@ -318,14 +318,29 @@ class QR_LibOptions(BaseOptions):
f.write(dumps(lib))
f.write('\n')
@staticmethod
def find_layer(sexp, def_layer):
""" Determine the layer.
The user could move the footprint to the bottom layer """
# Look for the polys
poly = next(filter(lambda s: is_symbol('fp_poly', s), sexp), None)
if not poly:
return def_layer
layer = next(filter(lambda s: is_symbol('layer', s), poly), None)
if not layer or len(layer) != 2:
return def_layer
return layer[1]
def update_footprint(self, name, sexp, qr):
logger.debug('- Updating QR footprint: '+name)
# Compute the size
qrc, size, full_size, center, size_rect = compute_size(qr, is_sch=False)
# In which layer are the drawings? (default to the original)
layer = self.find_layer(sexp, qr.layer)
# Remove old drawing
sexp[:] = list(filter(lambda s: not is_symbol('fp_poly', s), sexp))
# Add the new drawings
sexp.extend(self.qr_draw_fp(size, size_rect, center, qrc, qr.pcb_negative, qr.layer, do_sep=False))
sexp.extend(self.qr_draw_fp(size, size_rect, center, qrc, qr.pcb_negative, layer, do_sep=False))
# Update the fields
for s in sexp:
if (is_symbol('fp_text', s) and len(s) > 2 and isinstance(s[1], Symbol) and s[1].value() == 'user' and