Remove some unnecessary plot.py capabilities

main
Nathan L. Conrad 5 years ago
parent eb46d026f8
commit 7fa81857af

@ -5,50 +5,14 @@ __copyright__ = 'Copyright 2020 ALT-TEKNIK LLC'
from argparse import ArgumentParser
from os import path, rename
from os.path import dirname, realpath
from pcbnew import B_Cu, B_Mask, Edge_Cuts, EXCELLON_WRITER, F_Cu, F_Fab, \
F_Mask, F_Paste, F_SilkS, FILLED, FromMils, LoadBoard, LSET, \
PCB_PLOT_PARAMS, PLOT_CONTROLLER, PLOT_FORMAT_GERBER, PLOT_FORMAT_PDF, \
TEXTE_PCB
from pcbnew import B_Cu, B_Mask, Edge_Cuts, EXCELLON_WRITER, F_Cu, F_Mask, \
FILLED, FromMils, LoadBoard, PCB_PLOT_PARAMS, PLOT_CONTROLLER, \
PLOT_FORMAT_GERBER, PLOT_FORMAT_PDF, TEXTE_PCB
from uuid import uuid1
_UNNAMED_PAD = ''
class _PadExclusion:
def __init__(self, ref, name=None):
self.__ref = ref
self.__name = (None if name is None
else self.__normalize_name(str(name)))
def exclude_from_layer(self, board, layer_num):
count = 0
layer_mask = ~2**layer_num
for pad in board.FindModuleByReference(self.__ref).Pads():
if ((self.__name is None or
self.__name == self.__normalize_name(pad.GetName())) and
pad.IsOnLayer(layer_num)):
pad_mask = int(pad.GetLayerSet().FmtHex().replace('_', ''), 16)
pad_hex = hex(pad_mask & layer_mask)
layers = LSET()
layers.ParseHex(pad_hex, len(pad_hex))
pad.SetLayerSet(layers)
count += 1
if count:
if self.__name:
descr = 'pad {}'.format(self.__name)
else:
descr = 'pad' if count == 1 else 'pads'
if self.__name is not None:
descr = 'unnamed {}'.format(descr)
print(' Excluded {} {}'.format(self.__ref, descr))
@staticmethod
def __normalize_name(name):
return _UNNAMED_PAD if name == '~' or name.isspace() else name
_BOARD_NAME = '2x10-dip-adapter'
_VERSION_TOKEN = 'X.Y.Z'
_GERBER_EXT_OVERRIDES = {F_Fab: 'gm1', Edge_Cuts: 'gko'}
_GERBER_EXT_OVERRIDES = {Edge_Cuts: 'gko'}
class _Layer:
@ -67,9 +31,6 @@ class _Layer:
self.__scale = 1.0 if not scale else scale
suffix = kwargs.get('suffix')
self.__suffix = '' if suffix is None else suffix
pad_exclusions = kwargs.get('pad_exclusions')
self.__pad_exclusions = (() if pad_exclusions is None
else pad_exclusions)
def plot(self, board_file, output_dir, version=None):
# Append the suffix for Gerber layers with file extension overrides to
@ -97,10 +58,6 @@ class _Layer:
drawing.SetText(text.replace(_VERSION_TOKEN, version))
print(' Replaced version text')
# Apply pad exclusions
for pad_exclusion in self.__pad_exclusions:
pad_exclusion.exclude_from_layer(board, self.__num)
# Create a plot controller
controller = PLOT_CONTROLLER(board)

Loading…
Cancel
Save