[BoardView] Added sub-PCBs support

This commit is contained in:
Salvador E. Tropea 2022-12-26 09:33:04 -03:00
parent 71f2894ef4
commit 5dacb969b1
7 changed files with 54 additions and 4 deletions

View File

@ -1492,6 +1492,12 @@ Notes:
- **`options`**: [dict] Options for the `boardview` output.
* Valid keys:
- **`output`**: [string='%f-%i%I%v.%x'] Filename for the output (%i=boardview, %x=brd). Affected by global options.
- `dnf_filter`: [string|list(string)='_none'] Name of the filter to mark components as not fitted.
A short-cut to use for simple cases where a variant is an overkill.
- `pre_transform`: [string|list(string)='_none'] Name of the filter to transform fields before applying other filters.
A short-cut to use for simple cases where a variant is an overkill.
- `variant`: [string=''] Board variant to apply.
Used for sub-PCBs.
- `category`: [string|list(string)=''] The category for this output. If not specified an internally defined category is used.
Categories looks like file system paths, i.e. PCB/fabrication/gerber.
- `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output.

View File

@ -97,8 +97,17 @@ outputs:
type: 'boardview'
dir: 'Example/boardview_dir'
options:
# [string|list(string)='_none'] Name of the filter to mark components as not fitted.
# A short-cut to use for simple cases where a variant is an overkill
dnf_filter: '_none'
# [string='%f-%i%I%v.%x'] Filename for the output (%i=boardview, %x=brd). Affected by global options
output: '%f-%i%I%v.%x'
# [string|list(string)='_none'] Name of the filter to transform fields before applying other filters.
# A short-cut to use for simple cases where a variant is an overkill
pre_transform: '_none'
# [string=''] Board variant to apply.
# Used for sub-PCBs
variant: ''
# BoM (Bill of Materials):
# This output can generate XYRS files (pick and place files).
# Is compatible with KiBoM, but doesn't need to update the XML netlist because the components

View File

@ -67,7 +67,7 @@ class AnyDrill(VariantOptions):
}
self._map_ext = {'hpgl': 'plt', 'ps': 'ps', 'gerber': 'gbr', 'dxf': 'dxf', 'svg': 'svg', 'pdf': 'pdf'}
self._unified_output = False
self.add_to_doc('variant', 'Used for sub-PCBs')
self.help_only_sub_pcbs()
def config(self, parent):
super().config(parent)

View File

@ -256,6 +256,9 @@ class VariantOptions(BaseOptions):
return []
return [c.ref for c in self._comps if not c.fitted or not c.included]
def help_only_sub_pcbs(self):
self.add_to_doc('variant', 'Used for sub-PCBs')
# Here just to avoid pulling pcbnew for this
@staticmethod
def to_mm(val):
@ -747,7 +750,7 @@ class VariantOptions(BaseOptions):
return True
def unfilter_pcb_components(self, board, do_3D=False, do_2D=True):
if not self._comps and not self._sub_pcb:
if not self.will_filter_pcb_components():
return
if self._sub_pcb:
# Undo the sub-PCB: just reload the PCB

View File

@ -8,7 +8,7 @@
import re
from pcbnew import SHAPE_POLY_SET
from .gs import GS
from .optionable import BaseOptions
from .out_base import VariantOptions
from .macros import macros, document, output_class # noqa: F401
from . import log
@ -150,7 +150,7 @@ def convert(pcb, brd):
brd.write("\n")
class BoardViewOptions(BaseOptions):
class BoardViewOptions(VariantOptions):
def __init__(self):
with document:
self.output = GS.def_global_output
@ -158,10 +158,14 @@ class BoardViewOptions(BaseOptions):
super().__init__()
self._expand_id = 'boardview'
self._expand_ext = 'brd'
self.help_only_sub_pcbs()
def run(self, output):
super().run(output)
self.filter_pcb_components(GS.board)
with open(output, 'wt') as f:
convert(GS.board, f)
self.unfilter_pcb_components(GS.board)
def get_targets(self, out_dir):
return [self._parent.expand_filename(out_dir, self.output)]

View File

@ -0,0 +1,11 @@
# Example KiBot config file
kibot:
version: 1
import:
- file: battery_pack_sub_pcbs.kibot.yaml
outputs:
- name: 'Board View Test'
comment: "Example of board view export"
type: boardview

View File

@ -0,0 +1,17 @@
# Example KiBot config file for a basic 3D stencil
kibot:
version: 1
import:
- file: battery_pack_sub_pcbs.kibot.yaml
outputs:
- name: 'stencil'
comment: "Creates a 3D printable stencil"
type: stencil_3d
dir: stencil/3D
- name: 'navigate'
comment: "Browse the results"
type: navigate_results
run_by_default: false