Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VCUT Comments Layer #677

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions docs/panelization/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ Use mousebites to
side without text.
- `textprolongation` - the same as above, just on the text side
- `textoffset` - offset of the text from the cut line
- `textLayer` - layer for the text to appear (default Edge.Cuts)
- `template` - a string template for text to render. Can contain variables
listed below, e.g., `V-CUT {pos_mm}`.
- `pos_mm`, `pos_inch` – position of the V-cut from the panel origin
Expand Down
58 changes: 32 additions & 26 deletions docs/panelization/python_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ include components sticking out of the board outline, you can specify tolerance
#### `appendBoard`
```
appendBoard(self, filename, destination, sourceArea=None, origin=Origin.Center,
rotationAngle=<pcbnew.EDA_ANGLE; proxy of <Swig Object of type 'EDA_ANGLE *' at 0x7f4b833f3120> >,
rotationAngle=<pcbnew.EDA_ANGLE; proxy of <Swig Object of type 'EDA_ANGLE *' at 0x7f7695aaa610> >,
shrink=False, tolerance=0, bufferOutline=1000, netRenamer=None,
refRenamer=None, inheritDrc=True, interpretAnnotations=True,
bakeText=False)
Expand Down Expand Up @@ -168,7 +168,7 @@ given radius. This operation simulares milling.
#### `addNPTHole`
```
addNPTHole(self, position, diameter, paste=False, ref=None,
excludedFromPos=False)
excludedFromPos=False, solderMaskMargin=None)
```
Add a drilled non-plated hole to the position (`VECTOR2I`) with given
diameter. The paste option allows to place the hole on the paste layers.
Expand All @@ -190,7 +190,7 @@ internal features of the board are not affected.
#### `addText`
```
addText(self, text, position,
orientation=<pcbnew.EDA_ANGLE; proxy of <Swig Object of type 'EDA_ANGLE *' at 0x7f4b833f37b0> >,
orientation=<pcbnew.EDA_ANGLE; proxy of <Swig Object of type 'EDA_ANGLE *' at 0x7f7695aab360> >,
width=1500000, height=1500000, thickness=300000,
hJustify=EDA_TEXT_HJUSTIFY_T.GR_TEXT_HJUSTIFY_CENTER,
vJustify=EDA_TEXT_VJUSTIFY_T.GR_TEXT_VJUSTIFY_CENTER,
Expand All @@ -214,7 +214,7 @@ Adds a horizontal V-CUT at pos (integer in KiCAD units).
#### `appendBoard`
```
appendBoard(self, filename, destination, sourceArea=None, origin=Origin.Center,
rotationAngle=<pcbnew.EDA_ANGLE; proxy of <Swig Object of type 'EDA_ANGLE *' at 0x7f4b833f3120> >,
rotationAngle=<pcbnew.EDA_ANGLE; proxy of <Swig Object of type 'EDA_ANGLE *' at 0x7f7695aaa610> >,
shrink=False, tolerance=0, bufferOutline=1000, netRenamer=None,
refRenamer=None, inheritDrc=True, interpretAnnotations=True,
bakeText=False)
Expand Down Expand Up @@ -334,7 +334,7 @@ copperFillNonBoardAreas(self, clearance=1000000,
layers=[<Layer.F_Cu: 0>, <Layer.B_Cu: 31>],
hatched=False, strokeWidth=1000000,
strokeSpacing=1000000,
orientation=<pcbnew.EDA_ANGLE; proxy of <Swig Object of type 'EDA_ANGLE *' at 0x7f4b833f3510> >)
orientation=<pcbnew.EDA_ANGLE; proxy of <Swig Object of type 'EDA_ANGLE *' at 0x7f7695aab450> >)
```
This function is deprecated, please, use panel features instead.

Expand Down Expand Up @@ -401,6 +401,12 @@ getProFilepath(self, path=None)
```
None

#### `hasErrors`
```
hasErrors(self)
```
Report if panel has any non-fatal errors presents

#### `inheritCopperLayers`
```
inheritCopperLayers(self, board)
Expand All @@ -416,6 +422,12 @@ inheritDesignSettings(self, board)
Inherit design settings from the given board specified by a filename or
a board

#### `inheritLayerNames`
```
inheritLayerNames(self, board)
```
None

#### `inheritPageSize`
```
inheritPageSize(self, board)
Expand Down Expand Up @@ -448,7 +460,7 @@ expandDist - the distance by which to expand the board outline in each direction

#### `makeCutsToLayer`
```
makeCutsToLayer(self, cuts, layer=Layer.Cmts_User, prolongation=0)
makeCutsToLayer(self, cuts, layer=Layer.Cmts_User, prolongation=0, width=300000)
```
Take a list of cuts and render them as lines on given layer. The cuts
can be prolonged just like with mousebites.
Expand Down Expand Up @@ -480,9 +492,9 @@ minWidth - if the panel doesn't meet this width, it is extended

minHeight - if the panel doesn't meet this height, it is extended

maxWidth - if the panel doesn't meet this width, TooLargeError is raised
maxWidth - if the panel doesn't meet this width, error is set and marked

maxHeight - if the panel doesn't meet this height, TooLargeHeight is raised
maxHeight - if the panel doesn't meet this height, error is set and marked

#### `makeFrameCutsH`
```
Expand All @@ -499,7 +511,7 @@ Generate vertical cuts for the frame corners and return them
#### `makeGrid`
```
makeGrid(self, boardfile, sourceArea, rows, cols, destination, placer,
rotation=<pcbnew.EDA_ANGLE; proxy of <Swig Object of type 'EDA_ANGLE *' at 0x7f4b833f3f00> >,
rotation=<pcbnew.EDA_ANGLE; proxy of <Swig Object of type 'EDA_ANGLE *' at 0x7f7695aabb70> >,
netRenamePattern=Board_{n}-{orig}, refRenamePattern=Board_{n}-{orig},
tolerance=0, bakeText=False)
```
Expand Down Expand Up @@ -585,7 +597,7 @@ makeRailsTb(self, thickness, minHeight=0, maxHeight=None)
```
Adds a rail to top and bottom. You can specify minimal height the panel
has to feature. You can also specify maximal height of the panel. If the
height would be exceeded, TooLargeError is raised.
height would be exceeded, error is set.

#### `makeTightFrame`
```
Expand All @@ -609,17 +621,17 @@ minWidth - if the panel doesn't meet this width, it is extended

minHeight - if the panel doesn't meet this height, it is extended

maxWidth - if the panel doesn't meet this width, TooLargeError is raised
maxWidth - if the panel doesn't meet this width, error is set

maxHeight - if the panel doesn't meet this height, TooLargeHeight is raised
maxHeight - if the panel doesn't meet this height, error is set

#### `makeVCuts`
```
makeVCuts(self, cuts, boundCurves=False, offset=0)
```
Take a list of lines to cut and performs V-CUTS. When boundCurves is
set, approximate curved cuts by a line from the first and last point.
Otherwise, raise an exception.
Otherwise, make an approximate cut and report error.

#### `panelBBox`
```
Expand Down Expand Up @@ -653,9 +665,15 @@ vfirst and hfirst are indices of the first backbone to render. They are

Return a list of cuts

#### `reportError`
```
reportError(self, position, message)
```
Reports a non-fatal error. The error is marked and rendered to the panel

#### `save`
```
save(self, reconstructArcs=False, refillAllZones=False)
save(self, reconstructArcs=False, refillAllZones=False, edgeWidth=100000)
```
Saves the panel to a file and makes the requested changes to the prl and
pro files.
Expand Down Expand Up @@ -702,18 +720,6 @@ setTitleBlock(self, titleBlock)
```
Set panel title block

#### `setVCutClearance`
```
setVCutClearance(self, clearance)
```
Set V-cut clearance

#### `setVCutLayer`
```
setVCutLayer(self, layer)
```
Set layer on which the V-Cuts will be rendered

#### `transferProjectSettings`
```
transferProjectSettings(self)
Expand Down
10 changes: 6 additions & 4 deletions kikit/panelize.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ class VCutSettings:
textProlongation: KiLength = fromMm(3)
layer: Layer = Layer.Cmts_User
textTemplate: str = "V-CUT {pos_mm}"
textLayer: Layer = Layer.Cmts_User
textOffset: KiLength = fromMm(3)
clearance: KiLength = 0

Expand Down Expand Up @@ -1196,7 +1197,7 @@ def _setVCutLabelStyle(self, label, origin, position):
"pos_inv_inch": f"{(origin - position) / inch:.3f} mm",
}
label.SetText(self.vCutSettings.textTemplate.format(**variables))
label.SetLayer(self.vCutSettings.layer)
label.SetLayer(self.vCutSettings.textLayer)
label.SetTextThickness(self.vCutSettings.textThickness)
label.SetTextSize(toKiCADPoint((self.vCutSettings.textSize, self.vCutSettings.textSize)))
label.SetHorizJustify(EDA_TEXT_HJUSTIFY_T.GR_TEXT_HJUSTIFY_LEFT)
Expand All @@ -1221,10 +1222,11 @@ def _renderVCutV(self):
bBox.GetY() + bBox.GetHeight())
segments.append((segment, keepout))

label = pcbnew.PCB_TEXT(segment)
label = pcbnew.PCB_TEXT(self.board)
self._setVCutLabelStyle(label, self.getAuxiliaryOrigin()[0], cut)
label.SetPosition(toKiCADPoint((cut, minY - self.vCutSettings.textOffset)))
label.SetTextAngle(fromDegrees(90))
#label.SetLayer(self.vCutSettings.textLayer)
segments.append((label, None))
return segments

Expand All @@ -1248,10 +1250,10 @@ def _renderVCutH(self):
cut + self.vCutSettings.clearance / 2)
segments.append((segment, keepout))


label = pcbnew.PCB_TEXT(segment)
label = pcbnew.PCB_TEXT(self.board)
self._setVCutLabelStyle(label, self.getAuxiliaryOrigin()[1], cut)
label.SetPosition(toKiCADPoint((maxX + self.vCutSettings.textOffset, cut)))
#label.SetLayer(self.vCutSettings.textLayer)
segments.append((label, None))
return segments

Expand Down
1 change: 1 addition & 0 deletions kikit/panelize_ui_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ def makeCuts(properties, panel, cuts, ignoreOffset):
panel.vCutSettings.textProlongation = properties["textprolongation"]
panel.vCutSettings.endProlongation = properties["endprolongation"]
panel.vCutSettings.textTemplate = properties["template"]
panel.vCutSettings.textLayer = properties["textLayer"]
panel.vCutSettings.textOffset = properties["textoffset"]

elif type == "mousebites":
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 @@ -463,6 +463,9 @@ def ppTabs(section):
"layer": SLayer(
typeIn(["vcuts", "layer", "plugin"]),
"Specify layer for the drawings"),
"textLayer": SLayer(
typeIn(["vcuts", "textLayer", "plugin"]),
"Specify layer for the text comments for the vcuts"),
"code": SPlugin(
plugin.CutsPlugin,
typeIn(["plugin"]),
Expand Down
1 change: 1 addition & 0 deletions kikit/resources/panelizePresets/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"textprolongation": "3mm",
"textoffset": "3mm",
"template": "V-CUT",
"textLayer": "Cmts.User",
"layer": "Cmts.User",
"offset": "0mm",
"prolong": "0mm",
Expand Down
8 changes: 8 additions & 0 deletions test/system/panelize.bats
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ load common
--debug 'trace: true; deterministic: true' \
$RES/conn.kicad_pcb panel_t1.kicad_pcb
}
@test "Simple grid, no space, vcuts, text template" {
kikit panelize \
--layout 'grid; rows: 2; cols: 2;' \
--tabs full \
--cuts 'vcuts; template: TEST-V-CUT {pos_mm}; templateLayer: F.Fab' \
--debug 'trace: true; deterministic: true' \
$RES/conn.kicad_pcb panel-vcut-template.kicad_pcb
}

@test "Simple grid, spacing, vcuts" {
kikit panelize \
Expand Down