Added support to generate negative X positions for the bottom layer
This commit is contained in:
parent
007fc36d1e
commit
0f7a55dc8b
|
|
@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
with the path.
|
||||
- A hint for pip installations without using `--no-compile`.
|
||||
- Support to field overwrite according to variant.
|
||||
- Support to generate negative X positions for the bottom layer.
|
||||
### Fixed
|
||||
- Now we support missing field names in schematic library entries.
|
||||
|
||||
|
|
|
|||
|
|
@ -1080,6 +1080,7 @@ Next time you need this list just use an alias, like this:
|
|||
- `name`: [string=''] Used to identify this particular output definition.
|
||||
- `options`: [dict] Options for the `position` output.
|
||||
* Valid keys:
|
||||
- `bottom_negative_x`: [boolean=false] use negative X coordinates for footprints on bottom layer.
|
||||
- `columns`: [list(dict)|list(string)] which columns are included in the output.
|
||||
* Valid keys:
|
||||
- `id`: [string=''] [Ref,Val,Package,PosX,PosY,Rot,Side] Internal name.
|
||||
|
|
|
|||
|
|
@ -700,6 +700,8 @@ outputs:
|
|||
type: 'position'
|
||||
dir: 'Example/position_dir'
|
||||
options:
|
||||
# [boolean=false] use negative X coordinates for footprints on bottom layer
|
||||
bottom_negative_x: false
|
||||
# [list(dict)|list(string)] which columns are included in the output
|
||||
columns:
|
||||
# [string=''] [Ref,Val,Package,PosX,PosY,Rot,Side] Internal name
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ class PositionOptions(VariantOptions):
|
|||
""" [millimeters,inches] units used for the positions """
|
||||
self.columns = PosColumns
|
||||
""" [list(dict)|list(string)] which columns are included in the output """
|
||||
self.bottom_negative_x = False
|
||||
""" use negative X coordinates for footprints on bottom layer """
|
||||
super().__init__()
|
||||
|
||||
def config(self):
|
||||
|
|
@ -217,7 +219,10 @@ class PositionOptions(VariantOptions):
|
|||
elif k == 'Package':
|
||||
row.append(str(m.GetFPID().GetLibItemName())) # pcbnew.UTF8 type
|
||||
elif k == 'PosX':
|
||||
row.append("{:.4f}".format(center.x * conv))
|
||||
pos_x = center.x * conv
|
||||
if self.bottom_negative_x and m.IsFlipped():
|
||||
pos_x = -pos_x
|
||||
row.append("{:.4f}".format(pos_x))
|
||||
elif k == 'PosY':
|
||||
row.append("{:.4f}".format(-center.y * conv))
|
||||
elif k == 'Rot':
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ CSV_EXPR = r'^"%s",[^,]+,[^,]+,"([-\d\.]+)","([-\d\.]+)","([-\d\.]+)","(\S+)"$'
|
|||
ASCII_EXPR = r'^%s\s+\S+\s+\S+\s+([-\d\.]+)\s+([-\d\.]+)\s+([-\d\.]+)\s+(\S+)\s*$'
|
||||
|
||||
|
||||
def expect_position(ctx, file, comp, no_comp=[], inches=False, csv=False):
|
||||
def expect_position(ctx, file, comp, no_comp=[], inches=False, csv=False, neg_x=False):
|
||||
"""
|
||||
Check if a list of components are or aren't in the file
|
||||
"""
|
||||
|
|
@ -51,6 +51,8 @@ def expect_position(ctx, file, comp, no_comp=[], inches=False, csv=False):
|
|||
if inches:
|
||||
x = x/25.4
|
||||
y = y/25.4
|
||||
if neg_x:
|
||||
x = -x
|
||||
matches = res.pop(0)
|
||||
assert(abs(float(x) - float(matches[0])) < 0.001)
|
||||
assert(abs(float(y) + float(matches[1])) < 0.001)
|
||||
|
|
@ -79,6 +81,18 @@ def test_3Rs_position_1():
|
|||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_3Rs_position_neg_x():
|
||||
ctx = context.TestContext('3Rs_position_neg_x', '3Rs', 'simple_position_neg_x', POS_DIR)
|
||||
ctx.run()
|
||||
pos_top = ctx.get_pos_top_filename()
|
||||
pos_bot = ctx.get_pos_bot_filename()
|
||||
ctx.expect_out_file(pos_top)
|
||||
ctx.expect_out_file(pos_bot)
|
||||
expect_position(ctx, pos_top, ['R1'], ['R2', 'R3'])
|
||||
expect_position(ctx, pos_bot, ['R2'], ['R1', 'R3'], neg_x=True)
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_3Rs_position_unified():
|
||||
ctx = context.TestContext('3Rs_position_unified', '3Rs', 'simple_position_unified', POS_DIR)
|
||||
ctx.run()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
# Example KiBot config file for a basic 2-layer board
|
||||
kibot:
|
||||
version: 1
|
||||
|
||||
outputs:
|
||||
|
||||
- name: 'position'
|
||||
comment: "Pick and place file"
|
||||
type: position
|
||||
dir: positiondir
|
||||
options:
|
||||
format: ASCII # CSV or ASCII format
|
||||
units: millimeters # millimeters or inches
|
||||
separate_files_for_front_and_back: true
|
||||
only_smd: true
|
||||
bottom_negative_x: true
|
||||
Loading…
Reference in New Issue