Added option to copy plot options from the PCB to the YAML example.

Also added DXF.metric_units and updated the README.
This commit is contained in:
Salvador E. Tropea 2020-07-01 20:43:03 -03:00
parent 3685e3cb8b
commit ec35d2443f
20 changed files with 255 additions and 86 deletions

View File

@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- -e/--schematic option to specify any schematic (not just derived from the PCB
name.
- -x/--example option to generate a complete configuration example.
- --example supports --copy-options to copy the plot options from the PCB file.
- Help for the supported outputs (--help-list-outputs, --help-outputs and
--help-output)
- Help for the supported preflights (--help-preflights)
@ -27,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added HPGL options:
- pen_number
- pen_speed
- Added metric_units to DXF options
- Added the following InteractiveHtmlBom options:
- dark_mode
- hide_pads

View File

@ -203,6 +203,7 @@ Most options are the same you'll find in the KiCad dialogs.
- `exclude_edge_layer`: [boolean=true] do not include the PCB edge layer.
- `exclude_pads_from_silkscreen`: [boolean=false] do not plot the component pads in the silk screen.
- `force_plot_invisible_refs_vals`: [boolean=false] include references and values even when they are marked as invisible.
- `metric_units`: [boolean=false] use mm instead of inches.
- `plot_footprint_refs`: [boolean=true] include the footprint references.
- `plot_footprint_values`: [boolean=true] include the footprint values.
- `plot_sheet_reference`: [boolean=false] currently without effect.
@ -248,7 +249,7 @@ Most options are the same you'll find in the KiCad dialogs.
- `exclude_pads_from_silkscreen`: [boolean=false] do not plot the component pads in the silk screen.
- `force_plot_invisible_refs_vals`: [boolean=false] include references and values even when they are marked as invisible.
- `gerber_precision`: [number=4.6] this the gerber coordinate format, can be 4.5 or 4.6.
- `line_width`: [number=0.1] line_width for objects without width [mm].
- `line_width`: [number=0.1] [0.02,2] line_width for objects without width [mm].
- `plot_footprint_refs`: [boolean=true] include the footprint references.
- `plot_footprint_values`: [boolean=true] include the footprint values.
- `plot_sheet_reference`: [boolean=false] currently without effect.
@ -269,7 +270,9 @@ Most options are the same you'll find in the KiCad dialogs.
- `exclude_pads_from_silkscreen`: [boolean=false] do not plot the component pads in the silk screen.
- `force_plot_invisible_refs_vals`: [boolean=false] include references and values even when they are marked as invisible.
- `mirror_plot`: [boolean=false] plot mirrored.
- `pen_width`: [number=0.5] pen diameter in MILS, useful to fill areas. However, it is in mm in HPGL files.
- `pen_number`: [number=1] [1,16] pen number.
- `pen_speed`: [number=20] [1,99] pen speed.
- `pen_width`: [number=15] [0,100] pen diameter in MILS, useful to fill areas. However, it is in mm in HPGL files.
- `plot_footprint_refs`: [boolean=true] include the footprint references.
- `plot_footprint_values`: [boolean=true] include the footprint values.
- `plot_sheet_reference`: [boolean=false] currently without effect.
@ -334,7 +337,7 @@ Most options are the same you'll find in the KiCad dialogs.
- `exclude_edge_layer`: [boolean=true] do not include the PCB edge layer.
- `exclude_pads_from_silkscreen`: [boolean=false] do not plot the component pads in the silk screen.
- `force_plot_invisible_refs_vals`: [boolean=false] include references and values even when they are marked as invisible.
- `line_width`: [number=0.1] for objects without width [mm].
- `line_width`: [number=0.1] [0.02,2] for objects without width [mm].
- `mirror_plot`: [boolean=false] plot mirrored.
- `negative_plot`: [boolean=false] invert black and white.
- `plot_footprint_refs`: [boolean=true] include the footprint references.
@ -378,7 +381,7 @@ Most options are the same you'll find in the KiCad dialogs.
- `exclude_edge_layer`: [boolean=true] do not include the PCB edge layer.
- `exclude_pads_from_silkscreen`: [boolean=false] do not plot the component pads in the silk screen.
- `force_plot_invisible_refs_vals`: [boolean=false] include references and values even when they are marked as invisible.
- `line_width`: [number=0.15] for objects without width [mm].
- `line_width`: [number=0.15] [0.02,2] for objects without width [mm].
- `mirror_plot`: [boolean=false] plot mirrored.
- `negative_plot`: [boolean=false] invert black and white.
- `plot_footprint_refs`: [boolean=true] include the footprint references.
@ -416,7 +419,7 @@ Most options are the same you'll find in the KiCad dialogs.
- `exclude_edge_layer`: [boolean=true] do not include the PCB edge layer.
- `exclude_pads_from_silkscreen`: [boolean=false] do not plot the component pads in the silk screen.
- `force_plot_invisible_refs_vals`: [boolean=false] include references and values even when they are marked as invisible.
- `line_width`: [number=0.25] for objects without width [mm].
- `line_width`: [number=0.25] [0.02,2] for objects without width [mm].
- `mirror_plot`: [boolean=false] plot mirrored.
- `negative_plot`: [boolean=false] invert black and white.
- `plot_footprint_refs`: [boolean=true] include the footprint references.
@ -442,6 +445,12 @@ If you want to use the layers of a particular PCB in the example use:
kiplot -b PCB_FILE --example
```
And if you want to use the same options selected in the plot dialog use:
```
kiplot -b PCB_FILE -p --example
```
If the current directory contains only one PCB file and only one configuration file (named *.kiplot.yaml)
you can just call `kiplot`. No arguments needed. The tool will figure out which files to use.
@ -510,7 +519,7 @@ Usage:
kiplot [-b BOARD] [-e SCHEMA] [-c CONFIG] [-d OUT_DIR] [-s PRE]
[-q | -v...] [-i] [TARGET...]
kiplot [-c PLOT_CONFIG] --list
kiplot [-b BOARD] [-d OUT_DIR] --example
kiplot [-b BOARD] [-d OUT_DIR] [-p] --example
kiplot --help-list-outputs
kiplot --help-output=HELP_OUTPUT
kiplot --help-outputs
@ -533,6 +542,7 @@ Options:
--help-preflights List supported preflights and details
-i, --invert-sel Generate the outputs not listed as targets
-l, --list List available outputs (in the config file)
-p, --copy-options Copy plot options from the PCB file
-q, --quiet Remove information logs
-s PRE, --skip-pre PRE Skip preflights, comma separated or `all`
-v, --verbose Show debugging information

View File

@ -6,5 +6,6 @@ all: ../README.md samples/generic_plot.kiplot.yaml
cat README.in | perl replace_tags.pl > ../README.md
samples/generic_plot.kiplot.yaml: ../kiplot/out_*.py ../kiplot/pre_*.py ../kiplot/config_reader.py
rm -f example.kiplot.yaml
../src/kiplot --example
mv example.kiplot.yaml $@

View File

@ -211,6 +211,12 @@ If you want to use the layers of a particular PCB in the example use:
kiplot -b PCB_FILE --example
```
And if you want to use the same options selected in the plot dialog use:
```
kiplot -b PCB_FILE -p --example
```
If the current directory contains only one PCB file and only one configuration file (named *.kiplot.yaml)
you can just call `kiplot`. No arguments needed. The tool will figure out which files to use.

View File

@ -34,6 +34,8 @@ outputs:
exclude_pads_from_silkscreen: false
# [boolean=false] include references and values even when they are marked as invisible
force_plot_invisible_refs_vals: false
# [boolean=false] use mm instead of inches
metric_units: false
# [boolean=true] include the footprint references
plot_footprint_refs: true
# [boolean=true] include the footprint values
@ -168,7 +170,7 @@ outputs:
force_plot_invisible_refs_vals: false
# [number=4.6] this the gerber coordinate format, can be 4.5 or 4.6
gerber_precision: 4.6
# [number=0.1] line_width for objects without width [mm]
# [number=0.1] [0.02,2] line_width for objects without width [mm]
line_width: 0.1
# [boolean=true] include the footprint references
plot_footprint_refs: true
@ -267,8 +269,12 @@ outputs:
force_plot_invisible_refs_vals: false
# [boolean=false] plot mirrored
mirror_plot: false
# [number=0.5] pen diameter in MILS, useful to fill areas. However, it is in mm in HPGL files
pen_width: 0.5
# [number=1] [1,16] pen number
pen_number: 1
# [number=20] [1,99] pen speed
pen_speed: 20
# [number=15] [0,100] pen diameter in MILS, useful to fill areas. However, it is in mm in HPGL files
pen_width: 15
# [boolean=true] include the footprint references
plot_footprint_refs: true
# [boolean=true] include the footprint values
@ -435,7 +441,7 @@ outputs:
exclude_pads_from_silkscreen: false
# [boolean=false] include references and values even when they are marked as invisible
force_plot_invisible_refs_vals: false
# [number=0.1] for objects without width [mm]
# [number=0.1] [0.02,2] for objects without width [mm]
line_width: 0.1
# [boolean=false] plot mirrored
mirror_plot: false
@ -627,7 +633,7 @@ outputs:
exclude_pads_from_silkscreen: false
# [boolean=false] include references and values even when they are marked as invisible
force_plot_invisible_refs_vals: false
# [number=0.15] for objects without width [mm]
# [number=0.15] [0.02,2] for objects without width [mm]
line_width: 0.15
# [boolean=false] plot mirrored
mirror_plot: false
@ -751,7 +757,7 @@ outputs:
exclude_pads_from_silkscreen: false
# [boolean=false] include references and values even when they are marked as invisible
force_plot_invisible_refs_vals: false
# [number=0.25] for objects without width [mm]
# [number=0.25] [0.02,2] for objects without width [mm]
line_width: 0.25
# [boolean=false] plot mirrored
mirror_plot: false

View File

@ -5,7 +5,7 @@ Usage:
kiplot [-b BOARD] [-e SCHEMA] [-c CONFIG] [-d OUT_DIR] [-s PRE]
[-q | -v...] [-i] [TARGET...]
kiplot [-c PLOT_CONFIG] --list
kiplot [-b BOARD] [-d OUT_DIR] --example
kiplot [-b BOARD] [-d OUT_DIR] [-p] --example
kiplot --help-list-outputs
kiplot --help-output=HELP_OUTPUT
kiplot --help-outputs
@ -28,6 +28,7 @@ Options:
--help-preflights List supported preflights and details
-i, --invert-sel Generate the outputs not listed as targets
-l, --list List available outputs (in the config file)
-p, --copy-options Copy plot options from the PCB file
-q, --quiet Remove information logs
-s PRE, --skip-pre PRE Skip preflights, comma separated or `all`
-v, --verbose Show debugging information
@ -172,7 +173,10 @@ def main():
sys.exit(0)
if args.example:
check_board_file(args.board_file)
create_example(args.board_file, GS.out_dir)
if args.copy_options and not args.board_file:
logger.error('Asked to copy options but no PCB specified.')
sys.exit(EXIT_BAD_ARGS)
create_example(args.board_file, GS.out_dir, args.copy_options)
sys.exit(0)
# Determine the YAML file

View File

@ -303,7 +303,7 @@ def print_preflights_help():
print('- {}: {}.'.format(n, help.rstrip()))
def create_example(pcb_file, out_dir):
def create_example(pcb_file, out_dir, copy_options):
if not os.path.exists(out_dir):
os.makedirs(out_dir)
fname = os.path.join(out_dir, EXAMPLE_CFG)
@ -324,15 +324,21 @@ def create_example(pcb_file, out_dir):
outs = BaseOutput.get_registered()
f.write('\noutputs:\n')
# List of layers
po = None
if pcb_file:
# We have a PCB to take as reference
load_board(pcb_file)
layers = Layer.get_pcb_layers()
board = load_board(pcb_file)
if copy_options:
# Layers and plot options from the PCB
layers = Layer.get_plot_layers()
po = board.GetPlotOptions()
else:
layers = Layer.get_pcb_layers()
else:
# Use the default list of layers
layers = Layer.get_default_layers()
for n, o in OrderedDict(sorted(outs.items())).items():
lines = trim(o.__doc__)
for n, cls in OrderedDict(sorted(outs.items())).items():
lines = trim(cls.__doc__)
if len(lines) == 0:
lines = ['Undocumented', 'No description']
f.write(' # '+lines[0].rstrip()+':\n')
@ -343,7 +349,9 @@ def create_example(pcb_file, out_dir):
f.write(" type: '{}'\n".format(n))
f.write(" dir: 'Example/{}_dir'\n".format(n))
f.write(" options:\n")
obj = o('', n, '')
obj = cls('', n, '')
if po:
obj.read_vals_from_po(po)
for k, v in BaseOutput.get_attrs_gen(obj):
help = getattr(obj, '_help_'+k)
if help:

View File

@ -12,6 +12,11 @@ class DrillMarks(object):
'small': PCB_PLOT_PARAMS.SMALL_DRILL_SHAPE,
'full': PCB_PLOT_PARAMS.FULL_DRILL_SHAPE,
}
_drill_marks_rev_map = {
PCB_PLOT_PARAMS.NO_DRILL_SHAPE: 'none',
PCB_PLOT_PARAMS.SMALL_DRILL_SHAPE: 'small',
PCB_PLOT_PARAMS.FULL_DRILL_SHAPE: 'full',
}
def __init__(self):
with document:
@ -30,3 +35,10 @@ class DrillMarks(object):
def config(self):
self._drill_marks = DrillMarks._drill_marks_map[self._drill_marks]
def _configure_plot_ctrl(self, po, output_dir):
# How we draw drill marks
po.SetDrillMarksType(self._drill_marks)
def read_vals_from_po(self, po):
self._drill_marks = DrillMarks._drill_marks_rev_map[po.GetDrillMarksType()]

View File

@ -78,6 +78,7 @@ class Layer(object):
}
# Names from the board file
pcb_layers = {}
plot_layers = {}
def __init__(self, name, suffix, desc):
self.id = pcbnew.UNDEFINED_LAYER
@ -94,14 +95,29 @@ class Layer(object):
Layer.pcb_layers[board.GetLayerName(id)] = id
@staticmethod
def get_pcb_layers():
def _get_layers(d_layers):
layers = []
for n, id in Layer.pcb_layers.items():
for n, id in d_layers.items():
s = n.replace('.', '_')
d = Layer.DEFAULT_LAYER_DESC.get(n)
layers.append(Layer(n, s, d))
return layers
@staticmethod
def get_pcb_layers():
return Layer._get_layers(Layer.pcb_layers)
@staticmethod
def set_plot_layers(board):
enabled = board.GetEnabledLayers().Seq()
for id in board.GetPlotOptions().GetLayerSelection().Seq():
if id in enabled:
Layer.plot_layers[board.GetLayerName(id)] = id
@staticmethod
def get_plot_layers():
return Layer._get_layers(Layer.plot_layers)
def get_layer_id_from_name(self, layer_cnt):
""" Get the pcbnew layer from the string provided in the config """
# Priority
@ -182,6 +198,7 @@ def load_board(pcb_file=None):
pcbnew.ZONE_FILLER(board).Fill(board.Zones())
# Now we know the names of the layers for this board
Layer.set_pcb_layers(board)
Layer.set_plot_layers(board)
except OSError as e:
logger.error('Error loading PCB file. Currupted?')
logger.error(e)

View File

@ -34,3 +34,4 @@ CMD_IBOM = 'generate_interactive_bom.py'
URL_IBOM = 'https://github.com/INTI-CMNB/InteractiveHtmlBom'
KICAD2STEP = 'kicad2step'
EXAMPLE_CFG = 'example.kiplot.yaml'
AUTO_SCALE = 0

View File

@ -1,5 +1,5 @@
import os
from pcbnew import (GERBER_JOBFILE_WRITER, PCB_PLOT_PARAMS, FromMM, PLOT_CONTROLLER, IsCopperLayer, SKETCH)
from pcbnew import (GERBER_JOBFILE_WRITER, PLOT_CONTROLLER, IsCopperLayer)
from .out_base import (BaseOutput)
from .error import (PlotError, KiPlotConfigurationError)
from .gs import (GS)
@ -7,10 +7,10 @@ from kiplot.macros import macros, document # noqa: F401
from . import log
logger = log.get_logger(__name__)
AUTO_SCALE = 0
class AnyLayer(BaseOutput):
""" Base class for: DXF, Gerber, HPGL, PDF, PS and SVG """
def __init__(self, name, type, description):
super(AnyLayer, self).__init__(name, type, description)
# We need layers, so we define it
@ -41,38 +41,17 @@ class AnyLayer(BaseOutput):
def _configure_plot_ctrl(self, po, output_dir):
logger.debug("Configuring plot controller for output")
po.SetOutputDirectory(output_dir)
po.SetLineWidth(FromMM(self.get_line_width()))
# Scaling/Autoscale
scaling = self.get_scaling()
if scaling == AUTO_SCALE:
po.SetAutoScale(True)
po.SetScale(1)
else:
po.SetAutoScale(False)
po.SetScale(scaling)
po.SetMirror(self.get_mirror_plot())
po.SetNegative(self.get_negative_plot())
po.SetPlotFrameRef(self.plot_sheet_reference)
po.SetPlotReference(self.plot_footprint_refs)
po.SetPlotValue(self.plot_footprint_values)
po.SetPlotInvisibleText(self.force_plot_invisible_refs_vals)
po.SetExcludeEdgeLayer(self.exclude_edge_layer)
po.SetPlotPadsOnSilkLayer(not self.exclude_pads_from_silkscreen)
po.SetUseAuxOrigin(self.get_use_aux_axis_as_origin())
po.SetPlotViaOnMaskLayer(not self.tent_vias)
# in general, false, but gerber will set it back later
po.SetUseGerberAttributes(False)
# Only useful for gerber outputs
po.SetCreateGerberJobFile(False)
# How we draw drill marks
po.SetDrillMarksType(self.get_drill_marks())
# We'll come back to this on a per-layer basis
po.SetSkipPlotNPTH_Pads(False)
if self.get_sketch_plot():
po.SetPlotMode(SKETCH)
def get_plot_format(self):
return self._plot_format
def run(self, output_dir, board):
# fresh plot controller
@ -103,11 +82,9 @@ class AnyLayer(BaseOutput):
is_cu = IsCopperLayer(id)
po.SetSkipPlotNPTH_Pads(is_cu)
plot_format = self.get_plot_format()
# Plot single layer to file
logger.debug("Opening plot file for layer `{}` format `{}`".format(l, plot_format))
if not plot_ctrl.OpenPlotfile(suffix, plot_format, desc):
logger.debug("Opening plot file for layer `{}` format `{}`".format(l, self._plot_format))
if not plot_ctrl.OpenPlotfile(suffix, self._plot_format, desc):
raise PlotError("OpenPlotfile failed!")
logger.debug("Plotting layer `{}` to `{}`".format(l, plot_ctrl.GetPlotFileName()))
@ -124,27 +101,18 @@ class AnyLayer(BaseOutput):
job_fn = base_fn+'-job.gbrjob'
jobfile_writer.CreateJobFile(job_fn)
# Default values
# We concentrate all the KiCad plot initialization in one place.
# Here we provide default values for settings not contained in an output object
# TODO: avoid them?
def get_line_width(self):
return self.line_width if 'line_width' in self.__dict__ else 0
def get_scaling(self):
return self.scaling if 'scaling' in self.__dict__ else 1
def get_mirror_plot(self):
return self.mirror_plot if 'mirror_plot' in self.__dict__ else False
def get_negative_plot(self):
return self.negative_plot if 'negative_plot' in self.__dict__ else False
def get_use_aux_axis_as_origin(self):
return self.use_aux_axis_as_origin if 'use_aux_axis_as_origin' in self.__dict__ else False
def get_drill_marks(self):
return self.drill_marks if '_drill_marks' in self.__dict__ else PCB_PLOT_PARAMS.NO_DRILL_SHAPE
def get_sketch_plot(self):
return self.sketch_plot if 'sketch_plot' in self.__dict__ else False
def read_vals_from_po(self, po):
# excludeedgelayer
self.exclude_edge_layer = po.GetExcludeEdgeLayer()
# plotframeref
self.plot_sheet_reference = po.GetPlotFrameRef()
# plotreference
self.plot_footprint_refs = po.GetPlotReference()
# plotvalue
self.plot_footprint_values = po.GetPlotValue()
# plotinvisibletext
self.force_plot_invisible_refs_vals = po.GetPlotInvisibleText()
# viasonmask
self.tent_vias = not po.GetPlotViaOnMaskLayer()
# padsonsilk
self.exclude_pads_from_silkscreen = not po.GetPlotPadsOnSilkLayer()

View File

@ -1,5 +1,5 @@
import inspect
from re import (compile, match)
from re import (compile)
from .error import KiPlotConfigurationError
from . import log
@ -45,7 +45,7 @@ class BaseOutput(object):
logger.debug('Verificando')
min = float(m.group(1))
max = float(m.group(2))
if v<min or v>max:
if v < min or v > max:
raise KiPlotConfigurationError("Option `{}` outside its range [{},{}]".format(k, min, max))
elif isinstance(cur_val, str):
if not isinstance(v, str):
@ -104,6 +104,10 @@ class BaseOutput(object):
""" True for outputs that works on the PCB """
return not self._sch_related
def read_vals_from_po(self, po):
""" Set attributes from a PCB_PLOT_PARAMS (plot options) """
return
# These get_* aren't really needed.
# _* members aren't supposed to be used by the user, not the code.
def get_name(self):

View File

@ -1,4 +1,4 @@
from pcbnew import PLOT_FORMAT_DXF
from pcbnew import (PLOT_FORMAT_DXF, SKETCH, FILLED)
from kiplot.out_any_layer import AnyLayer
from kiplot.drill_marks import DrillMarks
from kiplot.macros import macros, document, output_class # noqa: F401
@ -20,6 +20,8 @@ class DXF(AnyLayer, DrillMarks):
""" use the auxiliar axis as origin for coordinates """
self.polygon_mode = True
""" plot using the contour, instead of the center line """
self.metric_units = False
""" use mm instead of inches """
self.sketch_plot = False
""" don't fill objects, just draw the outline """ # pragma: no cover
@ -29,4 +31,18 @@ class DXF(AnyLayer, DrillMarks):
def _configure_plot_ctrl(self, po, output_dir):
AnyLayer._configure_plot_ctrl(self, po, output_dir)
DrillMarks._configure_plot_ctrl(self, po, output_dir)
po.SetDXFPlotPolygonMode(self.polygon_mode)
# DXF_PLOTTER::DXF_UNITS isn't available
# According to https://docs.kicad-pcb.org/doxygen/classDXF__PLOTTER.html 1 is mm
po.SetDXFPlotUnits(1 if self.metric_units else 0)
po.SetPlotMode(SKETCH if self.sketch_plot else FILLED)
po.SetUseAuxOrigin(self.use_aux_axis_as_origin)
def read_vals_from_po(self, po):
AnyLayer.read_vals_from_po(self, po)
DrillMarks.read_vals_from_po(self, po)
self.polygon_mode = po.GetDXFPlotPolygonMode()
self.metric_units = po.GetDXFPlotUnits() == 1
self.sketch_plot = po.GetPlotMode() == SKETCH
self.use_aux_axis_as_origin = po.GetUseAuxOrigin()

View File

@ -1,4 +1,4 @@
from pcbnew import (PLOT_FORMAT_GERBER)
from pcbnew import (PLOT_FORMAT_GERBER, FromMM, ToMM)
from .out_any_layer import (AnyLayer)
from .error import KiPlotConfigurationError
from kiplot.macros import macros, document, output_class # noqa: F401
@ -44,10 +44,30 @@ class Gerber(AnyLayer):
def _configure_plot_ctrl(self, po, output_dir):
super()._configure_plot_ctrl(po, output_dir)
po.SetUseGerberAttributes(True)
po.SetSubtractMaskFromSilk(self.subtract_mask_from_silk)
po.SetUseGerberProtelExtensions(self.use_protel_extensions)
po.SetGerberPrecision(5 if self.gerber_precision == 4.5 else 6)
po.SetCreateGerberJobFile(self.create_gerber_job_file)
po.SetUseGerberAttributes(self.use_gerber_x2_attributes)
po.SetUseGerberX2format(self.use_gerber_x2_attributes)
po.SetIncludeGerberNetlistInfo(self.use_gerber_net_attributes)
po.SetUseAuxOrigin(self.use_aux_axis_as_origin)
po.SetLineWidth(FromMM(self.line_width))
def read_vals_from_po(self, po):
super().read_vals_from_po(po)
# usegerberattributes
self.use_gerber_x2_attributes = po.GetUseGerberX2format()
# usegerberextensions
self.use_protel_extensions = po.GetUseGerberProtelExtensions()
# usegerberadvancedattributes
self.use_gerber_net_attributes = po.GetIncludeGerberNetlistInfo()
# creategerberjobfile
self.create_gerber_job_file = po.GetCreateGerberJobFile()
# gerberprecision
self.gerber_precision = 4.0 + po.GetGerberPrecision()/10.0
# subtractmaskfromsilk
self.subtract_mask_from_silk = po.GetSubtractMaskFromSilk()
# useauxorigin
self.use_aux_axis_as_origin = po.GetUseAuxOrigin()
# linewidth
self.line_width = ToMM(po.GetLineWidth())

View File

@ -1,4 +1,5 @@
from pcbnew import PLOT_FORMAT_HPGL
from pcbnew import (PLOT_FORMAT_HPGL, SKETCH, FILLED)
from kiplot.misc import AUTO_SCALE
from kiplot.out_any_layer import AnyLayer
from kiplot.drill_marks import DrillMarks
from kiplot.macros import macros, document, output_class # noqa: F401
@ -33,7 +34,31 @@ class HPGL(AnyLayer, DrillMarks):
DrillMarks.config(self)
def _configure_plot_ctrl(self, po, output_dir):
super()._configure_plot_ctrl(po, output_dir)
AnyLayer._configure_plot_ctrl(self, po, output_dir)
DrillMarks._configure_plot_ctrl(self, po, output_dir)
po.SetHPGLPenDiameter(self.pen_width)
po.SetHPGLPenNum(self.pen_number)
po.SetHPGLPenSpeed(self.pen_speed)
po.SetPlotMode(SKETCH if self.sketch_plot else FILLED)
po.SetMirror(self.mirror_plot)
# Scaling/Autoscale
if self.scaling == AUTO_SCALE:
po.SetAutoScale(True)
po.SetScale(1)
else:
po.SetAutoScale(False)
po.SetScale(self.scaling)
def read_vals_from_po(self, po):
AnyLayer.read_vals_from_po(self, po)
DrillMarks.read_vals_from_po(self, po)
self.pen_width = po.GetHPGLPenDiameter()
self.pen_number = po.GetHPGLPenNum()
self.pen_speed = po.GetHPGLPenSpeed()
self.sketch_plot = po.GetPlotMode() == SKETCH
self.mirror_plot = po.GetMirror()
# scaleselection
if po.GetAutoScale():
self.scaling = AUTO_SCALE
else:
self.scaling = po.GetScale()

View File

@ -1,4 +1,4 @@
from pcbnew import PLOT_FORMAT_PDF
from pcbnew import (PLOT_FORMAT_PDF, FromMM, ToMM)
from kiplot.out_any_layer import AnyLayer
from kiplot.drill_marks import DrillMarks
from kiplot.macros import macros, document, output_class # noqa: F401
@ -26,3 +26,17 @@ class PDF(AnyLayer, DrillMarks):
def config(self, outdir, options, layers):
AnyLayer.config(self, outdir, options, layers)
DrillMarks.config(self)
def _configure_plot_ctrl(self, po, output_dir):
AnyLayer._configure_plot_ctrl(self, po, output_dir)
DrillMarks._configure_plot_ctrl(self, po, output_dir)
po.SetMirror(self.mirror_plot)
po.SetLineWidth(FromMM(self.line_width))
po.SetNegative(self.negative_plot)
def read_vals_from_po(self, po):
AnyLayer.read_vals_from_po(self, po)
DrillMarks.read_vals_from_po(self, po)
self.mirror_plot = po.GetMirror()
self.line_width = ToMM(po.GetLineWidth())
self.negative_plot = po.GetNegative()

View File

@ -1,4 +1,5 @@
from pcbnew import PLOT_FORMAT_POST
from pcbnew import (PLOT_FORMAT_POST, SKETCH, FILLED, FromMM, ToMM)
from kiplot.misc import AUTO_SCALE
from kiplot.out_any_layer import AnyLayer
from kiplot.drill_marks import DrillMarks
from kiplot.macros import macros, document, output_class # noqa: F401
@ -40,8 +41,37 @@ class PS(AnyLayer, DrillMarks):
DrillMarks.config(self)
def _configure_plot_ctrl(self, po, output_dir):
super()._configure_plot_ctrl(po, output_dir)
AnyLayer._configure_plot_ctrl(self, po, output_dir)
DrillMarks._configure_plot_ctrl(self, po, output_dir)
po.SetWidthAdjust(self.width_adjust)
po.SetFineScaleAdjustX(self.scale_adjust_x)
po.SetFineScaleAdjustX(self.scale_adjust_y)
po.SetA4Output(self.a4_output)
po.SetPlotMode(SKETCH if self.sketch_plot else FILLED)
po.SetLineWidth(FromMM(self.line_width))
po.SetNegative(self.negative_plot)
po.SetMirror(self.mirror_plot)
# Scaling/Autoscale
if self.scaling == AUTO_SCALE:
po.SetAutoScale(True)
po.SetScale(1)
else:
po.SetAutoScale(False)
po.SetScale(self.scaling)
def read_vals_from_po(self, po):
AnyLayer.read_vals_from_po(self, po)
DrillMarks.read_vals_from_po(self, po)
self.width_adjust = po.GetWidthAdjust()
self.scale_adjust_x = po.GetFineScaleAdjustX()
self.scale_adjust_y = po.GetFineScaleAdjustX()
self.a4_output = po.GetA4Output()
self.sketch_plot = po.GetPlotMode() == SKETCH
self.line_width = ToMM(po.GetLineWidth())
self.negative_plot = po.GetNegative()
self.mirror_plot = po.GetMirror()
# scaleselection
if po.GetAutoScale():
self.scaling = AUTO_SCALE
else:
self.scaling = po.GetScale()

View File

@ -1,4 +1,4 @@
from pcbnew import PLOT_FORMAT_SVG
from pcbnew import (PLOT_FORMAT_SVG, FromMM, ToMM)
from kiplot.out_any_layer import AnyLayer
from kiplot.drill_marks import DrillMarks
from kiplot.macros import macros, document, output_class # noqa: F401
@ -26,3 +26,17 @@ class SVG(AnyLayer, DrillMarks):
def config(self, outdir, options, layers):
AnyLayer.config(self, outdir, options, layers)
DrillMarks.config(self)
def _configure_plot_ctrl(self, po, output_dir):
AnyLayer._configure_plot_ctrl(self, po, output_dir)
DrillMarks._configure_plot_ctrl(self, po, output_dir)
po.SetMirror(self.mirror_plot)
po.SetLineWidth(FromMM(self.line_width))
po.SetNegative(self.negative_plot)
def read_vals_from_po(self, po):
AnyLayer.read_vals_from_po(self, po)
DrillMarks.read_vals_from_po(self, po)
self.line_width = ToMM(po.GetLineWidth())
self.negative_plot = po.GetNegative()
self.mirror_plot = po.GetMirror()

View File

@ -363,3 +363,13 @@ def test_example_3():
ctx.run(WONT_OVERWRITE, extra=['--example'], no_verbose=True, no_yaml_file=True)
os.remove(ctx.get_out_path(EXAMPLE_CFG))
ctx.clean_up()
def test_example_4():
ctx = context.TestContext('Example4', 'good-project', 'pre_and_position', '')
ctx.run(extra=['--example', '-p'], no_verbose=True, no_yaml_file=True)
assert ctx.expect_out_file(EXAMPLE_CFG)
ctx.search_in_file(EXAMPLE_CFG, ['GND.Cu'])
ctx.search_not_in_file(EXAMPLE_CFG, ['F.Adhes'])
os.remove(ctx.get_out_path(EXAMPLE_CFG))
ctx.clean_up()

View File

@ -16,11 +16,12 @@ outputs:
force_plot_invisible_refs_vals: false
tent_vias: true
# PS options
# DXF options
drill_marks: full
sketch_plot: false
use_aux_axis_as_origin: false
polygon_mode: true
metric_units: false
layers:
- layer: F.Cu
suffix: F_Cu