[Panelize] Added support for the plugin options

This commit is contained in:
Salvador E. Tropea 2022-12-02 10:51:53 -03:00
parent 3fd8dbf953
commit 3b963a195b
3 changed files with 87 additions and 27 deletions

View File

@ -2477,9 +2477,11 @@ Notes:
* Valid keys:
- **`cuts`**: [dict] Specify how to perform the cuts on the tabs separating the board.
* Valid keys:
- **`type`**: [string='none'] [none,mousebites,vcuts,layer] Layer: When KiKit reports it cannot perform cuts, you can render the cuts
- **`type`**: [string='none'] [none,mousebites,vcuts,layer,plugin] Layer: When KiKit reports it cannot perform cuts, you can render the cuts
into a layer with this option to understand what's going on. Shouldn't be used for the final design.
- `arg`: [string=''] Argument to pass to the plugin. Used for *plugin*.
- `clearance`: [number|string] Specify clearance for copper around V-cuts.
- `code`: [string=''] Plugin specification (PACKAGE.FUNCTION or PYTHON_FILE.FUNCTION). Used for *plugin*.
- *cut_curves*: Alias for cutcurves.
- `cutcurves`: [boolean=false] Specify if curves should be approximated by straight cuts (e.g., for cutting tabs on circular boards).
Used for *vcuts*.
@ -2492,7 +2494,7 @@ Notes:
- `spacing`: [number|string] The spacing of the holes used for the *mousebites*.
- **`fiducials`**: [dict] Used to add fiducial marks to the (rail/frame of) the panel.
* Valid keys:
- **`type`**: [string='none'] [none,3fid,4fid] Add none, 3 or 4 fiducials to the (rail/frame of) the panel.
- **`type`**: [string='none'] [none,3fid,4fid,plugin] Add none, 3 or 4 fiducials to the (rail/frame of) the panel.
- *copper_size*: Alias for coppersize.
- `coppersize`: [number|string] Diameter of the copper spot.
- `hoffset`: [number|string] Horizontal offset from panel edges.
@ -2500,12 +2502,15 @@ Notes:
- `voffset`: [number|string] Vertical offset from panel edges.
- **`framing`**: [dict] Specify the frame around the boards.
* Valid keys:
- **`type`**: [string='none'] [none,railstb,railslr,frame,tightframe] Railstb: Add rails on top and bottom.
- **`type`**: [string='none'] [none,railstb,railslr,frame,tightframe,plugin] Railstb: Add rails on top and bottom.
Railslr: Add rails on left and right.
Frame: Add a frame around the board.
Tighframe: Add a frame around the board which fills the whole area of the panel -
the boards have just a milled slot around their perimeter.
Plugin: Uses an external python function, only `code` and `arg` are relevant.
- `arg`: [string=''] Argument to pass to the plugin. Used for *plugin*.
- `chamfer`: [number|string] Specify the size of chamfer frame corners.
- `code`: [string=''] Plugin specification (PACKAGE.FUNCTION or PYTHON_FILE.FUNCTION). Used for *plugin*.
- `cuts`: [string='both'] [none,both,v,h] Specify whether to add cuts to the corners of the frame for easy removal.
Used for *frame*.
- `fillet`: [number|string] Specify radius of fillet frame corners.
@ -2530,8 +2535,10 @@ Notes:
rows: Rotate boards by 180° on every next row.
cols: Rotate boards by 180° on every next column.
rowsCols: Rotate boards by 180° based on a chessboard pattern.
- `arg`: [string=''] Argument to pass to the plugin. Used for *plugin*.
- *bake_text*: Alias for baketext.
- `baketext`: [boolean=true] A flag that indicates if text variables should be substituted or not.
- `code`: [string=''] Plugin specification (PACKAGE.FUNCTION or PYTHON_FILE.FUNCTION). Used for *plugin*.
- `hbackbone`: [number|string] The width of horizontal backbone (0 means no backbone). The backbone does not increase the
spacing of the boards.
- `hbonecut`: [boolean=true] If there are both backbones specified, specifies if there should be a horizontal cut where the backbones
@ -2545,7 +2552,7 @@ Notes:
name.
- `rotation`: [number|string] Rotate the boards before placing them in the panel.
- `space`: [number|string] Specify the gap between the boards, overwrites `hspace` and `vspace`.
- `type`: [string='grid'] [grid] Currently fixed.
- `type`: [string='grid'] [grid,plugin] In the plugin type only `code` and `arg` are relevant.
- `vbackbone`: [number|string] The width of vertical backbone (0 means no backbone). The backbone does not increase the
spacing of the boards.
- `vbonecut`: [boolean=true] If there are both backbones specified, specifies if there should be a vertical cut where the backbones
@ -2570,11 +2577,14 @@ Notes:
- `width`: [number|string] Width for the `custom` paper size.
- **`tabs`**: [dict] Style of the tabs used to join the PCB copies.
* Valid keys:
- **`type`**: [string='spacing'] [fixed,spacing,full,annotation] Fixed: Place given number of tabs on the PCB edge.
- **`type`**: [string='spacing'] [fixed,spacing,full,annotation,plugin] Fixed: Place given number of tabs on the PCB edge.
Spacing: Place tabs on the PCB edges based on spacing.
Full: Create tabs that are full width of the PCB.
Corner: Create tabs in the corners of the PCB.
Annotation: Add tabs based on PCB annotations.
Plugin: Uses an external python function, only `code` and `arg` are relevant.
- `arg`: [string=''] Argument to pass to the plugin. Used for *plugin*.
- `code`: [string=''] Plugin specification (PACKAGE.FUNCTION or PYTHON_FILE.FUNCTION). Used for *plugin*.
- `cutout`: [number|string] When your design features open pockets on the side, this parameter specifies extra cutout depth in order to
ensure that a sharp corner of the pocket can be milled. Used for *full*.
- `hcount`: [number=1] Number of tabs in the horizontal direction. Used for *fixed*.
@ -2591,7 +2601,9 @@ Notes:
Used for *fixed*, *spacing*, *corner* and *annotation*.
- **`tooling`**: [dict] Used to add tooling holes to the (rail/frame of) the panel.
* Valid keys:
- **`type`**: [string='none'] [none,3hole,4hole] Add none, 3 or 4 holes to the (rail/frame of) the panel.
- **`type`**: [string='none'] [none,3hole,4hole,plugin] Add none, 3 or 4 holes to the (rail/frame of) the panel.
- `arg`: [string=''] Argument to pass to the plugin. Used for *plugin*.
- `code`: [string=''] Plugin specification (PACKAGE.FUNCTION or PYTHON_FILE.FUNCTION). Used for *plugin*.
- `hoffset`: [number|string] Horizontal offset from panel edges.
- `paste`: [boolean=false] If True, the holes are included in the paste layer (therefore they appear on the stencil).
- `size`: [number|string] Diameter of the holes.
@ -2671,6 +2683,7 @@ Notes:
- `hoffset`: [number|string] Specify the horizontal offset from anchor. Respects KiCAD coordinate system.
- `layer`: [string='F.SilkS'] Specify text layer.
- `orientation`: [number|string] Specify the orientation (angle).
- `plugin`: [string=''] Specify the plugin that provides extra variables for the text.
- `thickness`: [number|string] Stroke thickness.
- `vjustify`: [string='center'] [left,right,center] Vertical justification of the text.
- `voffset`: [number|string] Specify the vertical offset from anchor. Respects KiCAD coordinate system.
@ -2693,6 +2706,7 @@ Notes:
- `hoffset`: [number|string] Specify the horizontal offset from anchor. Respects KiCAD coordinate system.
- `layer`: [string='F.SilkS'] Specify text layer.
- `orientation`: [number|string] Specify the orientation (angle).
- `plugin`: [string=''] Specify the plugin that provides extra variables for the text.
- `thickness`: [number|string] Stroke thickness.
- `vjustify`: [string='center'] [left,right,center] Vertical justification of the text.
- `voffset`: [number|string] Specify the vertical offset from anchor. Respects KiCAD coordinate system.
@ -2715,6 +2729,7 @@ Notes:
- `hoffset`: [number|string] Specify the horizontal offset from anchor. Respects KiCAD coordinate system.
- `layer`: [string='F.SilkS'] Specify text layer.
- `orientation`: [number|string] Specify the orientation (angle).
- `plugin`: [string=''] Specify the plugin that provides extra variables for the text.
- `thickness`: [number|string] Stroke thickness.
- `vjustify`: [string='center'] [left,right,center] Vertical justification of the text.
- `voffset`: [number|string] Specify the vertical offset from anchor. Respects KiCAD coordinate system.
@ -2737,6 +2752,7 @@ Notes:
- `hoffset`: [number|string] Specify the horizontal offset from anchor. Respects KiCAD coordinate system.
- `layer`: [string='F.SilkS'] Specify text layer.
- `orientation`: [number|string] Specify the orientation (angle).
- `plugin`: [string=''] Specify the plugin that provides extra variables for the text.
- `thickness`: [number|string] Stroke thickness.
- `vjustify`: [string='center'] [left,right,center] Vertical justification of the text.
- `voffset`: [number|string] Specify the vertical offset from anchor. Respects KiCAD coordinate system.

View File

@ -1244,8 +1244,12 @@ outputs:
width: 1
# [dict] Specify how to perform the cuts on the tabs separating the board
cuts:
# [string=''] Argument to pass to the plugin. Used for *plugin*
arg: ''
# [number|string] Specify clearance for copper around V-cuts
clearance: 0
# [string=''] Plugin specification (PACKAGE.FUNCTION or PYTHON_FILE.FUNCTION). Used for *plugin*
code: ''
# `cut_curves` is an alias for `cutcurves`
# [boolean=false] Specify if curves should be approximated by straight cuts (e.g., for cutting tabs on circular boards).
# Used for *vcuts*
@ -1262,7 +1266,7 @@ outputs:
prolong: 0
# [number|string] The spacing of the holes used for the *mousebites*
spacing: 0.8
# [string='none'] [none,mousebites,vcuts,layer] Layer: When KiKit reports it cannot perform cuts, you can render the cuts
# [string='none'] [none,mousebites,vcuts,layer,plugin] Layer: When KiKit reports it cannot perform cuts, you can render the cuts
# into a layer with this option to understand what's going on. Shouldn't be used for the final design
type: 'none'
# [dict] Debug options
@ -1290,14 +1294,18 @@ outputs:
hoffset: 0
# [number|string] Diameter of the solder mask opening
opening: 1
# [string='none'] [none,3fid,4fid] Add none, 3 or 4 fiducials to the (rail/frame of) the panel
# [string='none'] [none,3fid,4fid,plugin] Add none, 3 or 4 fiducials to the (rail/frame of) the panel
type: 'none'
# [number|string] Vertical offset from panel edges
voffset: 0
# [dict] Specify the frame around the boards
framing:
# [string=''] Argument to pass to the plugin. Used for *plugin*
arg: ''
# [number|string] Specify the size of chamfer frame corners
chamfer: 0
# [string=''] Plugin specification (PACKAGE.FUNCTION or PYTHON_FILE.FUNCTION). Used for *plugin*
code: ''
# [string='both'] [none,both,v,h] Specify whether to add cuts to the corners of the frame for easy removal.
# Used for *frame*
cuts: 'both'
@ -1318,11 +1326,12 @@ outputs:
slotwidth: 2
# [number|string] Specify the space between PCB and the frame/rail. Overrides `hspace` and `vspace`
space: null
# [string='none'] [none,railstb,railslr,frame,tightframe] Railstb: Add rails on top and bottom.
# [string='none'] [none,railstb,railslr,frame,tightframe,plugin] Railstb: Add rails on top and bottom.
# Railslr: Add rails on left and right.
# Frame: Add a frame around the board.
# Tighframe: Add a frame around the board which fills the whole area of the panel -
# the boards have just a milled slot around their perimeter
# the boards have just a milled slot around their perimeter.
# Plugin: Uses an external python function, only `code` and `arg` are relevant
type: 'none'
# [number|string] Specify the vertical space between PCB and the frame/rail
vspace: 2
@ -1336,9 +1345,13 @@ outputs:
# cols: Rotate boards by 180° on every next column.
# rowsCols: Rotate boards by 180° based on a chessboard pattern
alternation: 'none'
# [string=''] Argument to pass to the plugin. Used for *plugin*
arg: ''
# `bake_text` is an alias for `baketext`
# [boolean=true] A flag that indicates if text variables should be substituted or not
baketext: true
# [string=''] Plugin specification (PACKAGE.FUNCTION or PYTHON_FILE.FUNCTION). Used for *plugin*
code: ''
# [number=1] Specify the number of columns of boards in the grid pattern
cols: 1
# [number|string] The width of horizontal backbone (0 means no backbone). The backbone does not increase the
@ -1364,7 +1377,7 @@ outputs:
rows: 1
# [number|string] Specify the gap between the boards, overwrites `hspace` and `vspace`
space: null
# [string='grid'] [grid] Currently fixed
# [string='grid'] [grid,plugin] In the plugin type only `code` and `arg` are relevant
type: 'grid'
# [number|string] The width of vertical backbone (0 means no backbone). The backbone does not increase the
# spacing of the boards
@ -1455,6 +1468,10 @@ outputs:
type: 'auto'
# [dict] Style of the tabs used to join the PCB copies
tabs:
# [string=''] Argument to pass to the plugin. Used for *plugin*
arg: ''
# [string=''] Plugin specification (PACKAGE.FUNCTION or PYTHON_FILE.FUNCTION). Used for *plugin*
code: ''
# [number|string] When your design features open pockets on the side, this parameter specifies extra cutout depth in order to
# ensure that a sharp corner of the pocket can be milled. Used for *full*
cutout: 1
@ -1471,11 +1488,12 @@ outputs:
# `tab_footprints` is an alias for `tabfootprints`
# [string='kikit:Tab'] The footprint/s used for the *annotation* type. You can specify a list of footprints separated by comma
tabfootprints: 'kikit:Tab'
# [string='spacing'] [fixed,spacing,full,annotation] Fixed: Place given number of tabs on the PCB edge.
# [string='spacing'] [fixed,spacing,full,annotation,plugin] Fixed: Place given number of tabs on the PCB edge.
# Spacing: Place tabs on the PCB edges based on spacing.
# Full: Create tabs that are full width of the PCB.
# Corner: Create tabs in the corners of the PCB.
# Annotation: Add tabs based on PCB annotations
# Annotation: Add tabs based on PCB annotations.
# Plugin: Uses an external python function, only `code` and `arg` are relevant
type: 'spacing'
# [number=1] Number of tabs in the vertical direction. Used for *fixed*
vcount: 1
@ -1499,6 +1517,8 @@ outputs:
layer: 'F.SilkS'
# [number|string] Specify the orientation (angle)
orientation: 0
# [string=''] Specify the plugin that provides extra variables for the text
plugin: ''
# [string=''] The text to be displayed. Note that you can escape ; via \.
# Available variables in text: *date* formats current date as <year>-<month>-<day>,
# *time24* formats current time in 24-hour format,
@ -1533,6 +1553,8 @@ outputs:
layer: 'F.SilkS'
# [number|string] Specify the orientation (angle)
orientation: 0
# [string=''] Specify the plugin that provides extra variables for the text
plugin: ''
# [string=''] The text to be displayed. Note that you can escape ; via \.
# Available variables in text: *date* formats current date as <year>-<month>-<day>,
# *time24* formats current time in 24-hour format,
@ -1567,6 +1589,8 @@ outputs:
layer: 'F.SilkS'
# [number|string] Specify the orientation (angle)
orientation: 0
# [string=''] Specify the plugin that provides extra variables for the text
plugin: ''
# [string=''] The text to be displayed. Note that you can escape ; via \.
# Available variables in text: *date* formats current date as <year>-<month>-<day>,
# *time24* formats current time in 24-hour format,
@ -1601,6 +1625,8 @@ outputs:
layer: 'F.SilkS'
# [number|string] Specify the orientation (angle)
orientation: 0
# [string=''] Specify the plugin that provides extra variables for the text
plugin: ''
# [string=''] The text to be displayed. Note that you can escape ; via \.
# Available variables in text: *date* formats current date as <year>-<month>-<day>,
# *time24* formats current time in 24-hour format,
@ -1622,13 +1648,17 @@ outputs:
width: 1.5
# [dict] Used to add tooling holes to the (rail/frame of) the panel
tooling:
# [string=''] Argument to pass to the plugin. Used for *plugin*
arg: ''
# [string=''] Plugin specification (PACKAGE.FUNCTION or PYTHON_FILE.FUNCTION). Used for *plugin*
code: ''
# [number|string] Horizontal offset from panel edges
hoffset: 0
# [boolean=false] If True, the holes are included in the paste layer (therefore they appear on the stencil)
paste: false
# [number|string] Diameter of the holes
size: 1.152
# [string='none'] [none,3hole,4hole] Add none, 3 or 4 holes to the (rail/frame of) the panel
# [string='none'] [none,3hole,4hole,plugin] Add none, 3 or 4 holes to the (rail/frame of) the panel
type: 'none'
# [number|string] Vertical offset from panel edges
voffset: 0

View File

@ -80,6 +80,16 @@ class PanelOptions(BaseOptions):
raise KiPlotConfigurationError('Malformed number in `{}` ({})'.format(op, num))
class PanelOptionsWithPlugin(PanelOptions):
def __init__(self):
with document:
self.code = ''
""" Plugin specification (PACKAGE.FUNCTION or PYTHON_FILE.FUNCTION). Used for *plugin* """
self.arg = ''
""" Argument to pass to the plugin. Used for *plugin* """
super().__init__()
class PanelizePage(PanelOptions):
def __init__(self):
with document:
@ -114,11 +124,11 @@ class PanelizePage(PanelOptions):
self.add_units(('posx', 'posy', 'width', 'height'))
class PanelizeLayout(PanelOptions):
class PanelizeLayout(PanelOptionsWithPlugin):
def __init__(self):
with document:
self.type = 'grid'
""" [grid] Currently fixed """
""" [grid,plugin] In the plugin type only `code` and `arg` are relevant """
self.hspace = 0
""" [number|string] Specify the horizontal gap between the boards """
self.vspace = 0
@ -176,15 +186,16 @@ class PanelizeLayout(PanelOptions):
self.add_angle(('rotation', ))
class PanelizeTabs(PanelOptions):
class PanelizeTabs(PanelOptionsWithPlugin):
def __init__(self):
with document:
self.type = 'spacing'
""" *[fixed,spacing,full,annotation] Fixed: Place given number of tabs on the PCB edge.
""" *[fixed,spacing,full,annotation,plugin] Fixed: Place given number of tabs on the PCB edge.
Spacing: Place tabs on the PCB edges based on spacing.
Full: Create tabs that are full width of the PCB.
Corner: Create tabs in the corners of the PCB.
Annotation: Add tabs based on PCB annotations """
Annotation: Add tabs based on PCB annotations.
Plugin: Uses an external python function, only `code` and `arg` are relevant """
self.vwidth = 3
""" [number|string] The width of tabs in the vertical direction. Used for *fixed* and *spacing* """
self.hwidth = 3
@ -219,11 +230,11 @@ class PanelizeTabs(PanelOptions):
self.add_units(('vwidth', 'hwidth', 'width', 'mindistance', 'spacing', 'cutout'))
class PanelizeCuts(PanelOptions):
class PanelizeCuts(PanelOptionsWithPlugin):
def __init__(self):
with document:
self.type = 'none'
""" *[none,mousebites,vcuts,layer] Layer: When KiKit reports it cannot perform cuts, you can render the cuts
""" *[none,mousebites,vcuts,layer,plugin] Layer: When KiKit reports it cannot perform cuts, you can render the cuts
into a layer with this option to understand what's going on. Shouldn't be used for the final design """
self.drill = 0.5
""" [number|string] Drill size used for the *mousebites* """
@ -254,15 +265,16 @@ class PanelizeCuts(PanelOptions):
raise KiPlotConfigurationError('Must select only one layer for the V-cuts ({})'.format(self.layer))
class PanelizeFraming(PanelOptions):
class PanelizeFraming(PanelOptionsWithPlugin):
def __init__(self):
with document:
self.type = 'none'
""" *[none,railstb,railslr,frame,tightframe] Railstb: Add rails on top and bottom.
""" *[none,railstb,railslr,frame,tightframe,plugin] Railstb: Add rails on top and bottom.
Railslr: Add rails on left and right.
Frame: Add a frame around the board.
Tighframe: Add a frame around the board which fills the whole area of the panel -
the boards have just a milled slot around their perimeter """
the boards have just a milled slot around their perimeter.
Plugin: Uses an external python function, only `code` and `arg` are relevant """
self.hspace = 2
""" [number|string] Specify the horizontal space between PCB and the frame/rail """
self.vspace = 2
@ -302,11 +314,11 @@ class PanelizeFraming(PanelOptions):
'slotwidth'))
class PanelizeTooling(PanelOptions):
class PanelizeTooling(PanelOptionsWithPlugin):
def __init__(self):
with document:
self.type = 'none'
""" *[none,3hole,4hole] Add none, 3 or 4 holes to the (rail/frame of) the panel """
""" *[none,3hole,4hole,plugin] Add none, 3 or 4 holes to the (rail/frame of) the panel """
self.hoffset = 0
""" [number|string] Horizontal offset from panel edges """
self.voffset = 0
@ -326,7 +338,7 @@ class PanelizeFiducials(PanelOptions):
def __init__(self):
with document:
self.type = 'none'
""" *[none,3fid,4fid] Add none, 3 or 4 fiducials to the (rail/frame of) the panel """
""" *[none,3fid,4fid,plugin] Add none, 3 or 4 fiducials to the (rail/frame of) the panel """
self.hoffset = 0
""" [number|string] Horizontal offset from panel edges """
self.voffset = 0
@ -379,6 +391,8 @@ class PanelizeText(PanelOptions):
""" [number|string] Stroke thickness """
self.layer = 'F.SilkS'
""" Specify text layer """
self.plugin = ''
""" Specify the plugin that provides extra variables for the text """
super().__init__()
def config(self, parent):