[BoardView] Added sub-PCBs support
This commit is contained in:
parent
71f2894ef4
commit
5dacb969b1
|
|
@ -1492,6 +1492,12 @@ Notes:
|
||||||
- **`options`**: [dict] Options for the `boardview` output.
|
- **`options`**: [dict] Options for the `boardview` output.
|
||||||
* Valid keys:
|
* Valid keys:
|
||||||
- **`output`**: [string='%f-%i%I%v.%x'] Filename for the output (%i=boardview, %x=brd). Affected by global options.
|
- **`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.
|
- `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.
|
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.
|
- `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output.
|
||||||
|
|
|
||||||
|
|
@ -97,8 +97,17 @@ outputs:
|
||||||
type: 'boardview'
|
type: 'boardview'
|
||||||
dir: 'Example/boardview_dir'
|
dir: 'Example/boardview_dir'
|
||||||
options:
|
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
|
# [string='%f-%i%I%v.%x'] Filename for the output (%i=boardview, %x=brd). Affected by global options
|
||||||
output: '%f-%i%I%v.%x'
|
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):
|
# BoM (Bill of Materials):
|
||||||
# This output can generate XYRS files (pick and place files).
|
# 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
|
# Is compatible with KiBoM, but doesn't need to update the XML netlist because the components
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ class AnyDrill(VariantOptions):
|
||||||
}
|
}
|
||||||
self._map_ext = {'hpgl': 'plt', 'ps': 'ps', 'gerber': 'gbr', 'dxf': 'dxf', 'svg': 'svg', 'pdf': 'pdf'}
|
self._map_ext = {'hpgl': 'plt', 'ps': 'ps', 'gerber': 'gbr', 'dxf': 'dxf', 'svg': 'svg', 'pdf': 'pdf'}
|
||||||
self._unified_output = False
|
self._unified_output = False
|
||||||
self.add_to_doc('variant', 'Used for sub-PCBs')
|
self.help_only_sub_pcbs()
|
||||||
|
|
||||||
def config(self, parent):
|
def config(self, parent):
|
||||||
super().config(parent)
|
super().config(parent)
|
||||||
|
|
|
||||||
|
|
@ -256,6 +256,9 @@ class VariantOptions(BaseOptions):
|
||||||
return []
|
return []
|
||||||
return [c.ref for c in self._comps if not c.fitted or not c.included]
|
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
|
# Here just to avoid pulling pcbnew for this
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def to_mm(val):
|
def to_mm(val):
|
||||||
|
|
@ -747,7 +750,7 @@ class VariantOptions(BaseOptions):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def unfilter_pcb_components(self, board, do_3D=False, do_2D=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
|
return
|
||||||
if self._sub_pcb:
|
if self._sub_pcb:
|
||||||
# Undo the sub-PCB: just reload the PCB
|
# Undo the sub-PCB: just reload the PCB
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
import re
|
import re
|
||||||
from pcbnew import SHAPE_POLY_SET
|
from pcbnew import SHAPE_POLY_SET
|
||||||
from .gs import GS
|
from .gs import GS
|
||||||
from .optionable import BaseOptions
|
from .out_base import VariantOptions
|
||||||
from .macros import macros, document, output_class # noqa: F401
|
from .macros import macros, document, output_class # noqa: F401
|
||||||
from . import log
|
from . import log
|
||||||
|
|
||||||
|
|
@ -150,7 +150,7 @@ def convert(pcb, brd):
|
||||||
brd.write("\n")
|
brd.write("\n")
|
||||||
|
|
||||||
|
|
||||||
class BoardViewOptions(BaseOptions):
|
class BoardViewOptions(VariantOptions):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
with document:
|
with document:
|
||||||
self.output = GS.def_global_output
|
self.output = GS.def_global_output
|
||||||
|
|
@ -158,10 +158,14 @@ class BoardViewOptions(BaseOptions):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._expand_id = 'boardview'
|
self._expand_id = 'boardview'
|
||||||
self._expand_ext = 'brd'
|
self._expand_ext = 'brd'
|
||||||
|
self.help_only_sub_pcbs()
|
||||||
|
|
||||||
def run(self, output):
|
def run(self, output):
|
||||||
|
super().run(output)
|
||||||
|
self.filter_pcb_components(GS.board)
|
||||||
with open(output, 'wt') as f:
|
with open(output, 'wt') as f:
|
||||||
convert(GS.board, f)
|
convert(GS.board, f)
|
||||||
|
self.unfilter_pcb_components(GS.board)
|
||||||
|
|
||||||
def get_targets(self, out_dir):
|
def get_targets(self, out_dir):
|
||||||
return [self._parent.expand_filename(out_dir, self.output)]
|
return [self._parent.expand_filename(out_dir, self.output)]
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
Loading…
Reference in New Issue