Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions kikit/panelize.py
Original file line number Diff line number Diff line change
Expand Up @@ -2410,18 +2410,18 @@ def getFootprintByReference(board, reference):
return f
raise RuntimeError(f"Footprint with reference '{reference}' not found")

def extractSourceAreaByAnnotation(board, reference):
def extractSourceAreaByAnnotation(board, reference, layer=Layer.Edge_Cuts):
"""
Given a board and a reference to annotation in the form of symbol
`kikit:Board`, extract the source area. The source area is a bounding box of
continuous lines in the Edge.Cuts on which the arrow in reference point.
continuous lines in the specified layer on which the arrow in reference point.
"""
try:
annotation = getFootprintByReference(board, reference)
except Exception:
raise RuntimeError(f"Cannot extract board - boards is specified via footprint with reference '{reference}' which was not found")
tip = annotation.GetPosition()
edges = collectEdges(board, Layer.Edge_Cuts)
edges = collectEdges(board, layer)
# KiCAD 6 will need an adjustment - method Collide was introduced with
# different parameters. But v6 API is not available yet, so we leave this
# to future ourselves.
Expand Down
3 changes: 2 additions & 1 deletion kikit/panelize_ui_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ def readSourceArea(specification, board):
ref = specification["ref"]
if ref.strip() == "":
raise PresetError("When using source 'annotation' reference cannot be empty.")
return expandRect(extractSourceAreaByAnnotation(board, ref), tolerance)
layer = specification.get("layer", Layer.Edge_Cuts)
return expandRect(extractSourceAreaByAnnotation(board, ref, layer), tolerance)
if type == "rectangle":
tl = VECTOR2I(specification["tlx"], specification["tly"])
br = VECTOR2I(specification["brx"], specification["bry"])
Expand Down
3 changes: 3 additions & 0 deletions kikit/panelize_ui_sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ def ppLayout(section):
"ref": SStr(
typeIn(["annotation"]),
"Specify reference of KiKit annotation symbol"),
"layer": SLayer(
typeIn(["annotation"]),
"Specify layer for annotation lines (default: Edge.Cuts)"),
"stack": SChoice(
["inherit", "2layer", "4layer", "6layer"],
always(),
Expand Down