Added support to print the PCB in PDF format (using print, not plot)

This commit is contained in:
Salvador E. Tropea 2020-03-21 14:34:02 -03:00
parent d0d9c37064
commit 3aaf1ce045
4 changed files with 32 additions and 6 deletions

View File

@ -425,17 +425,18 @@ class CfgYamlReader(CfgReader):
layer = None
if s in D:
layer = PC.LayerInfo(D[s], False)
layer = PC.LayerInfo(D[s], False, s)
elif s.startswith("Inner"):
m = re.match(r"^Inner\.([0-9]+)$", s)
if not m:
raise YamlError("Malformed inner layer name: {}"
.format(s))
logger.error('Malformed inner layer name: '+s+', use Inner.N')
sys.exit(misc.EXIT_BAD_CONFIG)
layer = PC.LayerInfo(int(m.group(1)), True)
layer = PC.LayerInfo(int(m.group(1)), True, s)
else:
raise YamlError("Unknown layer name: {}".format(s))
logger.error('Unknown layer name: '+s)
sys.exit(misc.EXIT_BAD_CONFIG)
return layer
@ -492,6 +493,9 @@ class CfgYamlReader(CfgReader):
try:
layers = o_obj['layers']
except KeyError:
if otype == 'pdf_pcb_print':
logger.error('You must specify the layers for `'+name+'` ('+otype+')')
sys.exit(misc.EXIT_BAD_CONFIG)
layers = []
for l in layers:

View File

@ -566,6 +566,24 @@ class Plotter(object):
logger.debug('Moving '+cur+' -> '+new)
os.rename(cur,new)
def _do_pcb_print(self, board, plot_ctrl, output, brd_file):
check_script(misc.CMD_PCBNEW_PRINT_LAYERS,misc.URL_PCBNEW_PRINT_LAYERS,'1.1.2')
to = output.options.type_options
outdir = plot_ctrl.GetPlotOptions().GetOutputDirectory()
cmd = [misc.CMD_PCBNEW_PRINT_LAYERS,
'--output_name', to.output_name,
brd_file, outdir]
if logger.getEffectiveLevel() <= logging.DEBUG:
cmd.insert(1, '-vv')
cmd.insert(1, '-r')
# Add the layers
for l in output.layers:
cmd.append(l.layer.name)
logger.debug('Executing: '+str(cmd))
ret = call(cmd)
if ret:
logger.error(misc.CMD_PCBNEW_PRINT_LAYERS+' returned %d', ret)
exit(misc.PDF_PCB_PRINT)
def _do_bom(self, board, plot_ctrl, output, brd_file):
if output.options.type == 'kibom':

View File

@ -14,11 +14,14 @@ NO_SCH_FILE = 9
ERC_ERROR = 10
BOM_ERROR = 11
PDF_SCH_PRINT = 12
PDF_PCB_PRINT = 13
CMD_EESCHEMA_DO = 'eeschema_do'
URL_EESCHEMA_DO = 'https://github.com/INTI-CMNB/kicad-automation-scripts'
CMD_PCBNEW_RUN_DRC = 'pcbnew_run_drc'
URL_PCBNEW_RUN_DRC = URL_EESCHEMA_DO
CMD_PCBNEW_PRINT_LAYERS = 'pcbnew_print_layers'
URL_PCBNEW_PRINT_LAYERS = URL_EESCHEMA_DO
CMD_KIBOM = 'KiBOM_CLI.py'
URL_KIBOM = 'https://github.com/INTI-CMNB/KiBoM'
CMD_IBOM = 'generate_interactive_bom.py'

View File

@ -466,10 +466,11 @@ class OutputOptions(object):
class LayerInfo(object):
def __init__(self, layer, is_inner):
def __init__(self, layer, is_inner, name):
self.layer = layer
self.is_inner = is_inner
self.name = name
class LayerConfig(object):