Fixes position files, now defaults to use the auxiliar origin as KiCad.

Can be disabled to use absolute coordinates.
Fixes #87
This commit is contained in:
Salvador E. Tropea 2021-09-27 08:35:58 -03:00
parent b7b39d4bfe
commit a31002ed01
10 changed files with 132 additions and 3 deletions

View File

@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- skip_bottom: bottom components aren't rotated.
- XLSX BoM: option to control the logo scale (#84)
### Fixed
- Position files now defaults to use the auxiliar origin as KiCad.
Can be disabled to use absolute coordinates. (#87)
## [0.11.0] - 2021-04-25
### Added
- `erc_warnings` pre-flight option to consider ERC warnings as errors.

View File

@ -68,6 +68,8 @@ class PositionOptions(VariantOptions):
""" [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 """
self.use_aux_axis_as_origin = True
""" Use the auxiliary axis as origin for coordinates (KiCad default)"""
super().__init__()
self._expand_id = 'position'
@ -225,6 +227,11 @@ class PositionOptions(VariantOptions):
modules = []
is_pure_smd, is_not_virtual = self.get_attr_tests()
quote_char = '"' if self.format == 'CSV' else ''
x_origin = 0.0
y_origin = 0.0
if self.use_aux_axis_as_origin:
(x_origin, y_origin) = GS.board.GetAuxOrigin()
logger.debug('Using auxiliar origin: x={} y={}'.format(x_origin, y_origin))
for m in sorted(GS.board.GetModules(), key=lambda c: _ref_key(c.GetReference())):
ref = m.GetReference()
logger.debug('P&P ref: {}'.format(ref))
@ -258,12 +265,12 @@ class PositionOptions(VariantOptions):
elif k == 'Package':
row.append(quote_char+footprint+quote_char)
elif k == 'PosX':
pos_x = center.x * conv
pos_x = (center.x - x_origin) * conv
if self.bottom_negative_x and is_bottom:
pos_x = -pos_x
row.append("{:.4f}".format(pos_x))
elif k == 'PosY':
row.append("{:.4f}".format(-center.y * conv))
row.append("{:.4f}".format(-(center.y - y_origin) * conv))
elif k == 'Rot':
row.append("{:.4f}".format(rotation))
elif k == 'Side':

View File

@ -66,7 +66,7 @@
(pad_drill 0.762)
(pad_to_mask_clearance 0.051)
(solder_mask_min_width 0.25)
(aux_axis_origin 0 0)
(aux_axis_origin 102 102)
(visible_elements 7FFFFFFF)
(pcbplotparams
(layerselection 0x210f8_ffffffff)

View File

@ -0,0 +1,62 @@
Designator,Val,Package,Mid X,Mid Y,Rotation,Layer
"C1","1uF","R_0402_1005Metric",9.2000,32.1500,270.0000,top
"C2","0.1uF","R_0402_1005Metric",10.2000,32.1500,270.0000,top
"C3","4.7uF","R_0603_1608Metric",15.6020,35.7315,270.0000,top
"C4","1uF","R_0603_1608Metric",16.6000,20.7000,270.0000,top
"C5","22uF","R_0603_1608Metric",15.6000,30.7000,180.0000,top
"C6","4.7uF","R_0402_1005Metric",9.5060,40.0240,270.0000,top
"C7","10uF","R_0402_1005Metric",19.6660,39.2620,90.0000,top
"C8","0.1uF","R_0402_1005Metric",20.9360,39.2620,90.0000,top
"D1","D_Schottky","D_SOD-123",13.3000,21.0000,180.0000,top
"D2","D_Schottky","D_SOD-123",7.4000,33.2000,90.0000,top
"D3","D_Schottky","D_SOD-123",16.8000,13.1160,270.0000,top
"D4","D_Schottky","D_SOD-123",29.5000,12.1000,270.0000,top
"D5","D_Schottky","D_SOD-123",43.2880,14.1160,270.0000,top
"D6","D_Schottky","D_SOD-123",47.3000,22.6000,0.0000,top
"D7","D_Schottky","D_SOD-123",23.2000,13.1160,270.0000,top
"D8","D_Schottky","D_SOD-123",36.9000,12.0000,270.0000,top
"D9","D_Schottky","D_SOD-123",47.2000,16.5000,0.0000,top
"D10","D_Schottky","D_SOD-123",47.2000,28.7000,0.0000,top
"D11","Green","LED_0603_1608Metric",47.9000,38.2000,0.0000,top
"D12","Green","LED_0603_1608Metric",51.2000,38.2000,0.0000,top
"D13","Red","LED_0603_1608Metric",54.5000,38.2000,0.0000,top
"D14","Red","LED_0603_1608Metric",57.7000,38.2000,0.0000,top
"J2","USB_B_Micro","USB_Micro-B_Molex-105017-0001",3.4100,35.9600,270.0000,top
"Q1","Q_NPN_BEC","SOT-23",19.1580,35.9600,180.0000,top
"Q2","Q_NPN_BEC","SOT-23",19.1580,32.1500,180.0000,top
"Q3","Q_NMOS_GSD","SOT-23",19.8000,12.5920,90.0000,top
"Q4","Q_NMOS_GDS","SOT-23",32.6000,11.5000,90.0000,top
"Q5","Q_NMOS_GDS","SOT-23",46.5900,12.0840,90.0000,top
"Q6","Q_NMOS_GDS","SOT-23",47.8000,25.6000,180.0000,top
"Q7","Q_NMOS_GDS","SOT-23",26.2000,11.3220,90.0000,top
"Q8","Q_NMOS_GDS","SOT-23",39.9000,12.3380,90.0000,top
"Q9","Q_NMOS_GDS","SOT-23",47.8000,19.5000,180.0000,top
"Q10","Q_NMOS_GDS","SOT-23",47.8000,31.7000,180.0000,top
"R1","10kR","R_0402_1005Metric",15.6020,39.7700,180.0000,top
"R2","10kR","R_0402_1005Metric",15.6020,38.5000,180.0000,top
"R3","10kR","R_0402_1005Metric",8.2360,40.0240,270.0000,top
"R4","100R","R_0402_1005Metric",20.6820,15.3860,90.0000,top
"R5","100R","R_0402_1005Metric",32.2000,13.8000,0.0000,top
"R6","100R","R_0402_1005Metric",43.3000,17.1000,180.0000,top
"R7","100R","R_0402_1005Metric",45.4000,24.8850,90.0000,top
"R8","100R","R_0402_1005Metric",27.2860,13.7350,180.0000,top
"R9","100R","R_0402_1005Metric",39.1380,15.1480,0.0000,top
"R10","100R","R_0402_1005Metric",45.4470,19.4500,270.0000,top
"R11","100R","R_0402_1005Metric",45.3200,31.1000,270.0000,top
"R12","47R","R_0402_1005Metric",48.2000,36.7000,0.0000,top
"R13","47R","R_0402_1005Metric",51.0000,36.7000,0.0000,top
"R14","150R","R_0402_1005Metric",53.9000,36.7000,0.0000,top
"R15","150R","R_0402_1005Metric",57.0000,36.7000,0.0000,top
"R16","10kR","R_0402_1005Metric",24.2000,18.4000,180.0000,top
"R17","10kR","R_0402_1005Metric",19.1580,15.6400,0.0000,top
"R18","10kR","R_0402_1005Metric",34.2710,13.8620,180.0000,top
"R19","10kR","R_0402_1005Metric",42.3990,18.5610,0.0000,top
"R20","10kR","R_0402_1005Metric",43.9230,24.5300,90.0000,top
"R21","10kR","R_0402_1005Metric",25.3810,13.7350,0.0000,top
"R22","10kR","R_0402_1005Metric",40.7480,15.1320,270.0000,top
"R23","10kR","R_0402_1005Metric",42.3990,19.9580,0.0000,top
"R24","10kR","R_0402_1005Metric",45.3200,33.1430,270.0000,top
"SW1","SW_Push","TS-1187A",12.0000,43.8340,0.0000,top
"U1","AZ1117-3.3","SOT-223-3_TabPin2",15.3000,26.2000,180.0000,top
"U2","CP2104","QFN-24-1EP_4x4mm_P0.5mm_EP2.6x2.6mm",11.9040,35.9600,270.0000,top
"U3","ESP32-WROOM-32","ESP32-WROOM-32",32.3660,31.6420,0.0000,top
1 Designator Val Package Mid X Mid Y Rotation Layer
2 C1 1uF R_0402_1005Metric 9.2000 32.1500 270.0000 top
3 C2 0.1uF R_0402_1005Metric 10.2000 32.1500 270.0000 top
4 C3 4.7uF R_0603_1608Metric 15.6020 35.7315 270.0000 top
5 C4 1uF R_0603_1608Metric 16.6000 20.7000 270.0000 top
6 C5 22uF R_0603_1608Metric 15.6000 30.7000 180.0000 top
7 C6 4.7uF R_0402_1005Metric 9.5060 40.0240 270.0000 top
8 C7 10uF R_0402_1005Metric 19.6660 39.2620 90.0000 top
9 C8 0.1uF R_0402_1005Metric 20.9360 39.2620 90.0000 top
10 D1 D_Schottky D_SOD-123 13.3000 21.0000 180.0000 top
11 D2 D_Schottky D_SOD-123 7.4000 33.2000 90.0000 top
12 D3 D_Schottky D_SOD-123 16.8000 13.1160 270.0000 top
13 D4 D_Schottky D_SOD-123 29.5000 12.1000 270.0000 top
14 D5 D_Schottky D_SOD-123 43.2880 14.1160 270.0000 top
15 D6 D_Schottky D_SOD-123 47.3000 22.6000 0.0000 top
16 D7 D_Schottky D_SOD-123 23.2000 13.1160 270.0000 top
17 D8 D_Schottky D_SOD-123 36.9000 12.0000 270.0000 top
18 D9 D_Schottky D_SOD-123 47.2000 16.5000 0.0000 top
19 D10 D_Schottky D_SOD-123 47.2000 28.7000 0.0000 top
20 D11 Green LED_0603_1608Metric 47.9000 38.2000 0.0000 top
21 D12 Green LED_0603_1608Metric 51.2000 38.2000 0.0000 top
22 D13 Red LED_0603_1608Metric 54.5000 38.2000 0.0000 top
23 D14 Red LED_0603_1608Metric 57.7000 38.2000 0.0000 top
24 J2 USB_B_Micro USB_Micro-B_Molex-105017-0001 3.4100 35.9600 270.0000 top
25 Q1 Q_NPN_BEC SOT-23 19.1580 35.9600 180.0000 top
26 Q2 Q_NPN_BEC SOT-23 19.1580 32.1500 180.0000 top
27 Q3 Q_NMOS_GSD SOT-23 19.8000 12.5920 90.0000 top
28 Q4 Q_NMOS_GDS SOT-23 32.6000 11.5000 90.0000 top
29 Q5 Q_NMOS_GDS SOT-23 46.5900 12.0840 90.0000 top
30 Q6 Q_NMOS_GDS SOT-23 47.8000 25.6000 180.0000 top
31 Q7 Q_NMOS_GDS SOT-23 26.2000 11.3220 90.0000 top
32 Q8 Q_NMOS_GDS SOT-23 39.9000 12.3380 90.0000 top
33 Q9 Q_NMOS_GDS SOT-23 47.8000 19.5000 180.0000 top
34 Q10 Q_NMOS_GDS SOT-23 47.8000 31.7000 180.0000 top
35 R1 10kR R_0402_1005Metric 15.6020 39.7700 180.0000 top
36 R2 10kR R_0402_1005Metric 15.6020 38.5000 180.0000 top
37 R3 10kR R_0402_1005Metric 8.2360 40.0240 270.0000 top
38 R4 100R R_0402_1005Metric 20.6820 15.3860 90.0000 top
39 R5 100R R_0402_1005Metric 32.2000 13.8000 0.0000 top
40 R6 100R R_0402_1005Metric 43.3000 17.1000 180.0000 top
41 R7 100R R_0402_1005Metric 45.4000 24.8850 90.0000 top
42 R8 100R R_0402_1005Metric 27.2860 13.7350 180.0000 top
43 R9 100R R_0402_1005Metric 39.1380 15.1480 0.0000 top
44 R10 100R R_0402_1005Metric 45.4470 19.4500 270.0000 top
45 R11 100R R_0402_1005Metric 45.3200 31.1000 270.0000 top
46 R12 47R R_0402_1005Metric 48.2000 36.7000 0.0000 top
47 R13 47R R_0402_1005Metric 51.0000 36.7000 0.0000 top
48 R14 150R R_0402_1005Metric 53.9000 36.7000 0.0000 top
49 R15 150R R_0402_1005Metric 57.0000 36.7000 0.0000 top
50 R16 10kR R_0402_1005Metric 24.2000 18.4000 180.0000 top
51 R17 10kR R_0402_1005Metric 19.1580 15.6400 0.0000 top
52 R18 10kR R_0402_1005Metric 34.2710 13.8620 180.0000 top
53 R19 10kR R_0402_1005Metric 42.3990 18.5610 0.0000 top
54 R20 10kR R_0402_1005Metric 43.9230 24.5300 90.0000 top
55 R21 10kR R_0402_1005Metric 25.3810 13.7350 0.0000 top
56 R22 10kR R_0402_1005Metric 40.7480 15.1320 270.0000 top
57 R23 10kR R_0402_1005Metric 42.3990 19.9580 0.0000 top
58 R24 10kR R_0402_1005Metric 45.3200 33.1430 270.0000 top
59 SW1 SW_Push TS-1187A 12.0000 43.8340 0.0000 top
60 U1 AZ1117-3.3 SOT-223-3_TabPin2 15.3000 26.2000 180.0000 top
61 U2 CP2104 QFN-24-1EP_4x4mm_P0.5mm_EP2.6x2.6mm 11.9040 35.9600 270.0000 top
62 U3 ESP32-WROOM-32 ESP32-WROOM-32 32.3660 31.6420 0.0000 top

View File

@ -0,0 +1 @@
../5_1_6/light_control_cpl_jlc_aux.csv
1 ../5_1_6/light_control_cpl_jlc_aux.csv

View File

@ -0,0 +1 @@
../5_1_6/light_control_cpl_jlc_aux.csv
1 ../5_1_6/light_control_cpl_jlc_aux.csv

View File

@ -229,6 +229,16 @@ def test_position_rot_2(test_dir):
ctx.clean_up()
def test_position_rot_3(test_dir):
prj = 'light_control'
ctx = context.TestContext(test_dir, 'test_position_rot_3', prj, 'simple_position_rot_3', POS_DIR)
ctx.run(extra_debug=True)
output = prj+'_cpl_jlc_aux.csv'
ctx.expect_out_file(output)
ctx.compare_txt(output)
ctx.clean_up()
def test_rot_bottom(test_dir):
ctx = context.TestContext(test_dir, 'test_rot_bottom', 'comp_bottom', 'simple_position_rot_bottom', POS_DIR)
ctx.run()

View File

@ -29,6 +29,7 @@ outputs:
output: '%f_cpl_jlc.%x'
format: CSV
units: millimeters
use_aux_axis_as_origin: false
separate_files_for_front_and_back: false
only_smd: true
columns:

View File

@ -25,6 +25,7 @@ outputs:
output: '%f_cpl_jlc.%x'
format: CSV
units: millimeters
use_aux_axis_as_origin: false
separate_files_for_front_and_back: false
only_smd: true
columns:

View File

@ -0,0 +1,42 @@
kibot:
version: 1
filters:
- name: only_jlc_parts
comment: 'Only parts with JLC code'
type: generic
include_only:
- column: 'LCSC#'
regex: '^C\d+'
variants:
- name: rotated
comment: 'Just a place holder for the rotation filter'
type: kibom
variant: rotated
pre_transform: _rot_footprint
outputs:
- name: 'position'
comment: "Pick and place file, JLC style"
type: position
options:
variant: rotated
output: '%f_cpl_jlc_aux.%x'
format: CSV
units: millimeters
separate_files_for_front_and_back: false
only_smd: true
columns:
- id: Ref
name: Designator
- Val
- Package
- id: PosX
name: "Mid X"
- id: PosY
name: "Mid Y"
- id: Rot
name: Rotation
- id: Side
name: Layer