Skip to content

Commit b8e9a8f

Browse files
committed
fix(out_base): update 3D variant aspect matching logic
- Correct logic to select default 3D slot selection (added `any_matched`) - Renamed `default` to `default_slots` for clarity. - Add debug logging for variant matching - Apply default 3D models only if no variant matches
1 parent 3ec9b8d commit b8e9a8f

5 files changed

Lines changed: 13 additions & 7 deletions

File tree

107 KB
Loading
172 KB
Loading
189 KB
Loading

kibot/out_base.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,8 +724,8 @@ def apply_3D_variant_aspect(self, board, enable=False):
724724
for m in GS.get_modules_board(board):
725725
if extra_debug:
726726
logger.debug("Processing module " + m.GetReference())
727-
default = None
728-
matched = False
727+
default_slots = None
728+
any_matched = False
729729
# Look for text objects
730730
for gi in m.GraphicalItems():
731731
if gi.GetClass() in ['MTEXT', 'PCB_TEXT']:
@@ -737,13 +737,16 @@ def apply_3D_variant_aspect(self, board, enable=False):
737737
var = match.group(1)
738738
slots = match.group(2).split(',') if match.group(2) else []
739739
# Do the match
740+
matched = False
740741
if var == '_default_':
741-
default = slots
742+
default_slots = slots
742743
if self.extra_debug:
743-
logger.debug('- Found defaults: {}'.format(slots))
744+
logger.debug('- Found defaults: {}'.format(default_slots))
744745
else:
745746
matched = var == variant_name
747+
logger.debug(f'XXX 3D: Test {var} vs {variant_name}: {matched!r}. Slots: {slots}')
746748
if matched:
749+
any_matched = True
747750
self.apply_list_of_3D_models(enable, slots, m, var)
748751
break
749752
else:
@@ -752,13 +755,16 @@ def apply_3D_variant_aspect(self, board, enable=False):
752755
if match:
753756
var = match.group(1)
754757
slots = match.group(2).split(',') if match.group(2) else []
758+
755759
# Do the match
756760
matched = self.variant.matches_variant(var)
761+
logger.debug(f'XXX 3D: Test {var} vs {self.variant}: {matched!r}. Slots: {slots}')
757762
if matched:
763+
any_matched = True
758764
self.apply_list_of_3D_models(enable, slots, m, var)
759765
break
760-
if not matched and default is not None:
761-
self.apply_list_of_3D_models(enable, slots, m, '_default_')
766+
if not any_matched and default_slots is not None:
767+
self.apply_list_of_3D_models(enable, default_slots, m, '_default_')
762768

763769
def create_3D_highlight_file(self):
764770
if self._highlight_3D_file:

submodules/KiCost

Submodule KiCost updated 171 files

0 commit comments

Comments
 (0)