autolayout WIP
This commit is contained in:
parent
208701b981
commit
2327d932d3
5 changed files with 3401 additions and 6048 deletions
3304
fp-info-cache
3304
fp-info-cache
File diff suppressed because it is too large
Load diff
|
|
@ -4,6 +4,7 @@ import re
|
|||
import math
|
||||
|
||||
import gerbonara.cad.kicad.pcb as pcb
|
||||
import gerbonara.cad.primitives as cad_pr
|
||||
|
||||
|
||||
r = 85
|
||||
|
|
@ -26,22 +27,32 @@ b = pcb.Board.open('self-balancing-test-a.kicad_pcb')
|
|||
b.unfill_zones()
|
||||
|
||||
matches = list(b.find_footprints(name='Package_TO_SOT_SMD:SOT-23', sheetfile='resistor_bank.kicad_sch'))
|
||||
for i, fp in enumerate(matches):
|
||||
|
||||
for i, fp in enumerate(sorted(matches, key=lambda fp: fp.parsed_reference[1])):
|
||||
alpha = 2*math.pi * i/len(matches)
|
||||
fp.at.x, fp.at.y = cx+r, cy
|
||||
fp.set_rotation(0)
|
||||
fp.rotate(alpha, cx, cy)
|
||||
|
||||
res1, res2 = fp.pads_by_number[3].find_connected(name='Resistor_SMD.*')
|
||||
if parse_si(res1.property_value('Value')) > parse_si(res2.property_value('Value')):
|
||||
if parse_si(res1.value) > parse_si(res2.value):
|
||||
res1, res2 = res2, res1
|
||||
|
||||
res1.at.x, res1.at.y = cx+r+5, cy+2
|
||||
res1.set_rotation(0)
|
||||
res1.rotate(alpha, cx, cy)
|
||||
res1.face('right', net='*/V+')
|
||||
|
||||
res2.at.x, res2.at.y = cx+r+5, cy-2
|
||||
res2.set_rotation(0)
|
||||
res2.face('right', net='*/V+')
|
||||
|
||||
for tr in [
|
||||
cad_pr.Trace(0.5, fp.pad(3), res1.pad(2), orientation=['cw']),
|
||||
cad_pr.Trace(0.5, fp.pad(3), res2.pad(2))
|
||||
]:
|
||||
for obj in b.map_gn_cad(tr):
|
||||
obj.rotate(alpha, cx, cy)
|
||||
b.add(obj)
|
||||
|
||||
fp.rotate(alpha, cx, cy)
|
||||
res1.rotate(alpha, cx, cy)
|
||||
res2.rotate(alpha, cx, cy)
|
||||
|
||||
b.write('self-balancing-test-a.testout.kicad_pcb')
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ common_masses = {
|
|||
|
||||
|
||||
def angle_difference(a, b):
|
||||
return (b - a) % (2*math.pi) - math.pi
|
||||
return (b - a + math.pi) % (2*math.pi) - math.pi
|
||||
|
||||
def parse_mass(s):
|
||||
if not (m := re.match(r'^([0-9.,]*)([mkuµ]?)[g]?', s)):
|
||||
|
|
|
|||
|
|
@ -668,7 +668,7 @@
|
|||
(property "Value" "150" (at 123.19 82.55 90)
|
||||
(effects (font (size 1.27 1.27)) (justify right))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder" (at 116.84 83.312 90)
|
||||
(property "Footprint" "Resistor_SMD:R_1206_3216Metric" (at 116.84 83.312 90)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "~" (at 116.84 85.09 0)
|
||||
|
|
@ -709,7 +709,7 @@
|
|||
(property "Value" "100" (at 123.19 87.63 90)
|
||||
(effects (font (size 1.27 1.27)) (justify right))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder" (at 116.84 88.392 90)
|
||||
(property "Footprint" "Resistor_SMD:R_1206_3216Metric" (at 116.84 88.392 90)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "~" (at 116.84 90.17 0)
|
||||
|
|
@ -838,7 +838,7 @@
|
|||
(property "Value" "150" (at 123.19 110.49 90)
|
||||
(effects (font (size 1.27 1.27)) (justify right))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder" (at 116.84 111.252 90)
|
||||
(property "Footprint" "Resistor_SMD:R_1206_3216Metric" (at 116.84 111.252 90)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "~" (at 116.84 113.03 0)
|
||||
|
|
@ -879,7 +879,7 @@
|
|||
(property "Value" "150" (at 123.19 68.58 90)
|
||||
(effects (font (size 1.27 1.27)) (justify right))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder" (at 116.84 69.342 90)
|
||||
(property "Footprint" "Resistor_SMD:R_1206_3216Metric" (at 116.84 69.342 90)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "~" (at 116.84 71.12 0)
|
||||
|
|
@ -960,7 +960,7 @@
|
|||
(property "Value" "150" (at 123.19 138.43 90)
|
||||
(effects (font (size 1.27 1.27)) (justify right))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder" (at 116.84 139.192 90)
|
||||
(property "Footprint" "Resistor_SMD:R_1206_3216Metric" (at 116.84 139.192 90)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "~" (at 116.84 140.97 0)
|
||||
|
|
@ -1049,7 +1049,7 @@
|
|||
(property "Value" "100" (at 123.19 101.6 90)
|
||||
(effects (font (size 1.27 1.27)) (justify right))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder" (at 116.84 102.362 90)
|
||||
(property "Footprint" "Resistor_SMD:R_1206_3216Metric" (at 116.84 102.362 90)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "~" (at 116.84 104.14 0)
|
||||
|
|
@ -1090,7 +1090,7 @@
|
|||
(property "Value" "100" (at 123.19 129.54 90)
|
||||
(effects (font (size 1.27 1.27)) (justify right))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder" (at 116.84 130.302 90)
|
||||
(property "Footprint" "Resistor_SMD:R_1206_3216Metric" (at 116.84 130.302 90)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "~" (at 116.84 132.08 0)
|
||||
|
|
@ -1211,7 +1211,7 @@
|
|||
(property "Value" "150" (at 123.19 40.64 90)
|
||||
(effects (font (size 1.27 1.27)) (justify right))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder" (at 116.84 41.402 90)
|
||||
(property "Footprint" "Resistor_SMD:R_1206_3216Metric" (at 116.84 41.402 90)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "~" (at 116.84 43.18 0)
|
||||
|
|
@ -1252,7 +1252,7 @@
|
|||
(property "Value" "150" (at 123.19 54.61 90)
|
||||
(effects (font (size 1.27 1.27)) (justify right))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder" (at 116.84 55.372 90)
|
||||
(property "Footprint" "Resistor_SMD:R_1206_3216Metric" (at 116.84 55.372 90)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "~" (at 116.84 57.15 0)
|
||||
|
|
@ -1293,7 +1293,7 @@
|
|||
(property "Value" "100" (at 123.19 143.51 90)
|
||||
(effects (font (size 1.27 1.27)) (justify right))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder" (at 116.84 144.272 90)
|
||||
(property "Footprint" "Resistor_SMD:R_1206_3216Metric" (at 116.84 144.272 90)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "~" (at 116.84 146.05 0)
|
||||
|
|
@ -1470,7 +1470,7 @@
|
|||
(property "Value" "100" (at 123.19 73.66 90)
|
||||
(effects (font (size 1.27 1.27)) (justify right))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder" (at 116.84 74.422 90)
|
||||
(property "Footprint" "Resistor_SMD:R_1206_3216Metric" (at 116.84 74.422 90)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "~" (at 116.84 76.2 0)
|
||||
|
|
@ -1511,7 +1511,7 @@
|
|||
(property "Value" "100" (at 123.19 59.69 90)
|
||||
(effects (font (size 1.27 1.27)) (justify right))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder" (at 116.84 60.452 90)
|
||||
(property "Footprint" "Resistor_SMD:R_1206_3216Metric" (at 116.84 60.452 90)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "~" (at 116.84 62.23 0)
|
||||
|
|
@ -1552,7 +1552,7 @@
|
|||
(property "Value" "150" (at 123.19 124.46 90)
|
||||
(effects (font (size 1.27 1.27)) (justify right))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder" (at 116.84 125.222 90)
|
||||
(property "Footprint" "Resistor_SMD:R_1206_3216Metric" (at 116.84 125.222 90)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "~" (at 116.84 127 0)
|
||||
|
|
@ -1593,7 +1593,7 @@
|
|||
(property "Value" "100" (at 123.19 45.72 90)
|
||||
(effects (font (size 1.27 1.27)) (justify right))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder" (at 116.84 46.482 90)
|
||||
(property "Footprint" "Resistor_SMD:R_1206_3216Metric" (at 116.84 46.482 90)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "~" (at 116.84 48.26 0)
|
||||
|
|
@ -1674,7 +1674,7 @@
|
|||
(property "Value" "150" (at 123.19 96.52 90)
|
||||
(effects (font (size 1.27 1.27)) (justify right))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder" (at 116.84 97.282 90)
|
||||
(property "Footprint" "Resistor_SMD:R_1206_3216Metric" (at 116.84 97.282 90)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "~" (at 116.84 99.06 0)
|
||||
|
|
@ -1947,7 +1947,7 @@
|
|||
(property "Value" "100" (at 123.19 115.57 90)
|
||||
(effects (font (size 1.27 1.27)) (justify right))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder" (at 116.84 116.332 90)
|
||||
(property "Footprint" "Resistor_SMD:R_1206_3216Metric" (at 116.84 116.332 90)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "~" (at 116.84 118.11 0)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue