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 argparse import ArgumentParser
from os import path, rename from os import path, rename
from os.path import dirname, realpath from os.path import dirname, realpath
from pcbnew import B_Cu, B_Mask, Edge_Cuts, EXCELLON_WRITER, F_Cu, F_Fab, \ from pcbnew import B_Cu, B_Mask, Edge_Cuts, EXCELLON_WRITER, F_Cu, F_Mask, \
F_Mask, F_Paste, F_SilkS, FILLED, FromMils, LoadBoard, LSET, \ FILLED, FromMils, LoadBoard, PCB_PLOT_PARAMS, PLOT_CONTROLLER, \
PCB_PLOT_PARAMS, PLOT_CONTROLLER, PLOT_FORMAT_GERBER, PLOT_FORMAT_PDF, \ PLOT_FORMAT_GERBER, PLOT_FORMAT_PDF, TEXTE_PCB
TEXTE_PCB
from uuid import uuid1 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' _BOARD_NAME = '2x10-dip-adapter'
_VERSION_TOKEN = 'X.Y.Z' _VERSION_TOKEN = 'X.Y.Z'
_GERBER_EXT_OVERRIDES = {F_Fab: 'gm1', Edge_Cuts: 'gko'} _GERBER_EXT_OVERRIDES = {Edge_Cuts: 'gko'}
class _Layer: class _Layer:
@ -67,9 +31,6 @@ class _Layer:
self.__scale = 1.0 if not scale else scale self.__scale = 1.0 if not scale else scale
suffix = kwargs.get('suffix') suffix = kwargs.get('suffix')
self.__suffix = '' if suffix is None else 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): def plot(self, board_file, output_dir, version=None):
# Append the suffix for Gerber layers with file extension overrides to # Append the suffix for Gerber layers with file extension overrides to
@ -97,10 +58,6 @@ class _Layer:
drawing.SetText(text.replace(_VERSION_TOKEN, version)) drawing.SetText(text.replace(_VERSION_TOKEN, version))
print(' Replaced version text') 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 # Create a plot controller
controller = PLOT_CONTROLLER(board) controller = PLOT_CONTROLLER(board)

Loading…
Cancel
Save