Skip to content

Commit

Permalink
[Subparts Filter][Fixed] 3D ouputs
Browse files Browse the repository at this point in the history
See #729
  • Loading branch information
set-soft committed Nov 21, 2024
1 parent d96e2ec commit 42dc171
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- SubParts filter:
- iBoM and Schematic print didn't take it into account (#716)
- 3D outputs also ignored them (#729)
- BoM
- The field name `Reference` was accepted, but didn't work
- Do Not Fit footprint crosses:
Expand Down
1 change: 1 addition & 0 deletions docs/source/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Fixed
- SubParts filter:

- iBoM and Schematic print didn’t take it into account (#716)
- 3D outputs also ignored them (#729)

- BoM

Expand Down
18 changes: 16 additions & 2 deletions kibot/out_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,18 @@ def apply_footprint_variants(self, board, comps_hash):
logger.debug(f'Replacing footprints from variant change {to_change}')
replace_footprints(GS.pcb_file, to_change, logger, replace_pcb=False)

def add_parent_comps(self, c, comps):
if c.parent_component and c.parent_component.ref not in comps:
comps[c.parent_component.ref] = c.parent_component
self.add_parent_comps(c.parent_component, comps)

def include_parents(self, comps):
new_comps = {}
for ref, c in comps.items():
new_comps[ref] = c
self.add_parent_comps(c, new_comps)
return new_comps

def filter_pcb_components(self, do_3D=False, do_2D=True, highlight=None):
if not self.will_filter_pcb_components():
return False
Expand All @@ -881,7 +893,8 @@ def filter_pcb_components(self, do_3D=False, do_2D=True, highlight=None):
# Disable the models that aren't for this variant
self.apply_3D_variant_aspect(GS.board)
# Remove the 3D models for not fitted components (also rename)
self.remove_3D_models(GS.board, self._comps_hash)
comps_hash = self.include_parents(self._comps_hash)
self.remove_3D_models(GS.board, comps_hash)
# Highlight selected components
self.highlight_3D_models(GS.board, highlight)
return True
Expand All @@ -898,7 +911,8 @@ def unfilter_pcb_components(self, do_3D=False, do_2D=True):
self.restore_sch_fields_to_pcb(GS.board)
if do_3D and self._comps_hash:
# Undo the removing (also rename)
self.restore_3D_models(GS.board, self._comps_hash)
comps_hash = self.include_parents(self._comps_hash)
self.restore_3D_models(GS.board, comps_hash)
# Re-enable the modules that aren't for this variant
self.apply_3D_variant_aspect(GS.board, enable=True)
# Remove the highlight 3D object
Expand Down

0 comments on commit 42dc171

Please sign in to comment.