[Netlist] Added support for sub-PCBs

This commit is contained in:
Salvador E. Tropea 2022-12-26 11:00:06 -03:00
parent 3f74105c82
commit 819555e668
4 changed files with 41 additions and 8 deletions

View File

@ -2644,6 +2644,12 @@ Notes:
from the schematic. The `ipc` format is the IPC-D-356 format, useful for PCB
testing, is generated from the PCB.
- **`output`**: [string='%f-%i%I%v.%x'] Filename for the output (%i=netlist/IPC-D-356, %x=net/d356). 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

@ -1323,12 +1323,21 @@ outputs:
type: 'netlist'
dir: 'Example/netlist_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='classic'] [classic,ipc] The `classic` format is the KiCad internal format, and is generated
# from the schematic. The `ipc` format is the IPC-D-356 format, useful for PCB
# testing, is generated from the PCB
format: 'classic'
# [string='%f-%i%I%v.%x'] Filename for the output (%i=netlist/IPC-D-356, %x=net/d356). 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: ''
# Panelize:
# It currently uses the KiKit tool, which must be available.
# Consult KiKit docs for detailed information.

View File

@ -12,7 +12,7 @@ Dependencies:
"""
import os
from .gs import GS
from .optionable import BaseOptions
from .out_base import VariantOptions
from .misc import FAILED_EXECUTE
from .kiplot import exec_with_retry, add_extra_options
from .macros import macros, document, output_class # noqa: F401
@ -21,7 +21,7 @@ from . import log
logger = log.get_logger()
class NetlistOptions(BaseOptions):
class NetlistOptions(VariantOptions):
def __init__(self):
with document:
self.output = GS.def_global_output
@ -31,6 +31,7 @@ class NetlistOptions(BaseOptions):
from the schematic. The `ipc` format is the IPC-D-356 format, useful for PCB
testing, is generated from the PCB """
super().__init__()
self.help_only_sub_pcbs()
def config(self, parent):
super().config(parent)
@ -48,10 +49,12 @@ class NetlistOptions(BaseOptions):
def run(self, name):
command = self.ensure_tool('KiAuto')
super().run(name)
to_remove = []
if self.format == 'ipc':
command = command.replace('eeschema_do', 'pcbnew_do')
subcommand = 'ipc_netlist'
file = GS.pcb_file
file = self.save_tmp_board_if_variant(to_remove)
else:
subcommand = 'netlist'
file = GS.sch_file
@ -59,16 +62,16 @@ class NetlistOptions(BaseOptions):
# Output file name
cmd = [command, subcommand, '--output_name', name, file, output_dir]
cmd, video_remove = add_extra_options(cmd)
if video_remove:
to_remove.append(os.path.join(self.expand_filename_pcb(GS.out_dir), command[:-3]+'_'+subcommand+'_screencast.ogv'))
# Execute it
ret = exec_with_retry(cmd)
if ret:
logger.error(command+' returned %d', ret)
exit(FAILED_EXECUTE)
# Remove the video if needed
if video_remove:
video_name = os.path.join(self.expand_filename_pcb(GS.out_dir), command[:-3]+'_'+subcommand+'_screencast.ogv')
if os.path.isfile(video_name):
os.remove(video_name)
for f in to_remove:
if os.path.isfile(f):
os.remove(f)
@output_class

View File

@ -0,0 +1,15 @@
# This is a working example.
# For a more complete reference use `--example`
kibot:
version: 1
import:
- file: battery_pack_sub_pcbs.kibot.yaml
outputs:
- name: ipc_netlist
comment: IPC-D-356 netlist for testing
type: netlist
dir: Export
options:
format: ipc