Skip to content

Commit af80815

Browse files
committed
[Variants][Added][SubPCB] arbitrary layer for contour
- Defaults to Edge.Cuts See yaqwsx/KiKit#846
1 parent cbdfc8c commit af80815

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

kibot/out_pcbdraw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def config(self, parent):
264264
self.bottom = bot
265265
super().config(parent)
266266
# V-CUTS layer
267-
self._vcuts_layer = Layer.solve(self.vcuts_layer)[0]._id if self.vcuts else 41
267+
self._vcuts_layer = Layer.solve(self.vcuts_layer or 'Cmts.User')[0]._id
268268
# Highlight
269269
self._highlight = self.solve_kf_filters(self.highlight)
270270
# Margin

kibot/var_base.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from .optionable import Optionable, PanelOptions
1212
from .fil_base import apply_exclude_filter, apply_fitted_filter, apply_fixed_filter, apply_pre_transform
1313
from .error import KiPlotConfigurationError
14+
from .layer import Layer
1415
from .misc import KIKIT_UNIT_ALIASES
1516
from .gs import GS
1617
from .kiplot import run_command
@@ -72,6 +73,9 @@ def __init__(self):
7273
This is the reference for the `kikit:Board` footprint used to identify the sub-PCB.
7374
Note that you can use any footprint as long as its position is inside the PCB outline.
7475
When empty the sub-PCB is specified using a rectangle """
76+
self.ref_layer = 'Edge.Cuts'
77+
""" Layer where the PCB outline indicated by `reference` is found.
78+
So you can use an outline that is not the real PCB contour """
7579
self.ref = None
7680
""" {reference} """
7781
self.tlx = 0
@@ -129,10 +133,13 @@ def config(self, parent):
129133
if not self._tolerance and GS.ki5:
130134
# KiCad 5 workaround: rounding issues generate 1 fm of error. So we change to 2 fm tolerance.
131135
self._tolerance = 2
136+
# Reference layer
137+
self._ref_layer = Layer.solve(self.ref_layer or 'Edge.Cuts')[0]._id
132138

133139
def get_separate_source(self):
134140
if self.reference:
135141
src = "annotation; ref: {}".format(self.reference)
142+
# TODO: add self._ref_layer when https://github.com/yaqwsx/KiKit/pull/846 is available
136143
else:
137144
src = "rectangle; tlx: {}; tly: {}; brx: {}; bry: {}".format(self.tlx, self.tly, self.brx, self.bry)
138145
if self._tolerance:
@@ -213,7 +220,7 @@ def get_pcb_edges(self):
213220
""" Get a list of PCB shapes from the Edge.Cuts layer.
214221
Only useful elements are returned. """
215222
edges = []
216-
layer_cuts = GS.board.GetLayerID('Edge.Cuts')
223+
layer_cuts = self._ref_layer
217224
for edge in chain(GS.board.GetDrawings(), *[m.GraphicalItems() for m in GS.get_modules()]):
218225
if edge.GetLayer() != layer_cuts or edge.GetClass().startswith('PCB_DIM_') or not GS.is_valid_pcb_shape(edge):
219226
continue

0 commit comments

Comments
 (0)