|
11 | 11 | from .optionable import Optionable, PanelOptions
|
12 | 12 | from .fil_base import apply_exclude_filter, apply_fitted_filter, apply_fixed_filter, apply_pre_transform
|
13 | 13 | from .error import KiPlotConfigurationError
|
| 14 | +from .layer import Layer |
14 | 15 | from .misc import KIKIT_UNIT_ALIASES
|
15 | 16 | from .gs import GS
|
16 | 17 | from .kiplot import run_command
|
@@ -72,6 +73,9 @@ def __init__(self):
|
72 | 73 | This is the reference for the `kikit:Board` footprint used to identify the sub-PCB.
|
73 | 74 | Note that you can use any footprint as long as its position is inside the PCB outline.
|
74 | 75 | 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 """ |
75 | 79 | self.ref = None
|
76 | 80 | """ {reference} """
|
77 | 81 | self.tlx = 0
|
@@ -129,10 +133,13 @@ def config(self, parent):
|
129 | 133 | if not self._tolerance and GS.ki5:
|
130 | 134 | # KiCad 5 workaround: rounding issues generate 1 fm of error. So we change to 2 fm tolerance.
|
131 | 135 | self._tolerance = 2
|
| 136 | + # Reference layer |
| 137 | + self._ref_layer = Layer.solve(self.ref_layer or 'Edge.Cuts')[0]._id |
132 | 138 |
|
133 | 139 | def get_separate_source(self):
|
134 | 140 | if self.reference:
|
135 | 141 | src = "annotation; ref: {}".format(self.reference)
|
| 142 | + # TODO: add self._ref_layer when https://github.com/yaqwsx/KiKit/pull/846 is available |
136 | 143 | else:
|
137 | 144 | src = "rectangle; tlx: {}; tly: {}; brx: {}; bry: {}".format(self.tlx, self.tly, self.brx, self.bry)
|
138 | 145 | if self._tolerance:
|
@@ -213,7 +220,7 @@ def get_pcb_edges(self):
|
213 | 220 | """ Get a list of PCB shapes from the Edge.Cuts layer.
|
214 | 221 | Only useful elements are returned. """
|
215 | 222 | edges = []
|
216 |
| - layer_cuts = GS.board.GetLayerID('Edge.Cuts') |
| 223 | + layer_cuts = self._ref_layer |
217 | 224 | for edge in chain(GS.board.GetDrawings(), *[m.GraphicalItems() for m in GS.get_modules()]):
|
218 | 225 | if edge.GetLayer() != layer_cuts or edge.GetClass().startswith('PCB_DIM_') or not GS.is_valid_pcb_shape(edge):
|
219 | 226 | continue
|
|
0 commit comments