kicad: make footprint render layer_map argument optional

This commit is contained in:
jaseg 2025-12-08 11:52:42 +01:00
parent 42dfd1be7f
commit df4895abfa
2 changed files with 7 additions and 10 deletions

View file

@ -885,11 +885,14 @@ class Footprint:
(self.zones if zones else []),
self.groups if groups else [])
def render(self, layer_stack, layer_map, x=0, y=0, rotation=0, text=False, flip=False, variables={}, cache=None):
def render(self, layer_stack, layer_map=None, x=0, y=0, rotation=0, text=False, flip=False, variables={}, cache=None):
x += self.at.x
y += self.at.y
rotation += math.radians(self.at.rotation)
if layer_map is None:
layer_map = {kc_id: gn_id for kc_id, gn_id in LAYER_MAP_K2G.items() if gn_id in layer_stack}
for obj in self.objects(pads=False, text=text, zones=False, groups=False):
if not (layer := layer_map.get(obj.layer)):
continue
@ -946,8 +949,7 @@ class Footprint:
def bounding_box(self, unit=MM):
if not hasattr(self, '_bounding_box'):
stack = LayerStack()
layer_map = {kc_id: gn_id for kc_id, gn_id in LAYER_MAP_K2G.items() if gn_id in stack}
self.render(stack, layer_map, x=0, y=0, rotation=0, flip=False, text=False, variables={})
self.render(stack, layer_map=None, x=0, y=0, rotation=0, flip=False, text=False, variables={})
self._bounding_box = stack.bounding_box(unit)
return self._bounding_box
@ -972,9 +974,7 @@ class FootprintInstance(Positioned):
if self.value is not None:
variables['VALUE'] = str(self.value)
layer_map = {kc_id: gn_id for kc_id, gn_id in LAYER_MAP_K2G.items() if gn_id in layer_stack}
self.sexp.render(layer_stack, layer_map,
self.sexp.render(layer_stack, layer_map=None,
x=x, y=y, rotation=rotation,
flip=flip,
text=(not self.hide_text),

View file

@ -738,10 +738,7 @@ class LayerStack:
:param prefix: Store output files under the given prefix inside the zip file
"""
if path.is_file():
if overwrite_existing:
path.unlink()
else:
if path.is_file() and not overwrite_existing:
raise ValueError('output zip file already exists and overwrite_existing is False')
if gerber_settings and not excellon_settings: