Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env python3
import sys
sys.path.insert(1,'/home/jingyan/Documents/summer_intern_lemur/roco_electrical/dsn_python')
import dsnwritier
class brd_design():
def __init__(self,dwgfile,boundary_inx,libpath):
self.dwgfile=dwgfile
self.boundary_inx=boundary_inx
self.libpath=libpath
self.module_list=[
['mpu-9250.kicad_mod','J1',[103000,88000],270],
['ESP12F-Devkit-V3.kicad_mod','U1',[103000,48000],90],
]
self.netlist=[
['3v3',['U1-3','J1-1']],
['VIN',['U1-1']]
]
self.netclass_list=[
['default',['3v3','VIN'],'',1000,200]
]
self.brd_general()
self.boundary,self.keepout=self.load_drawing()
self.image,self.padstack=self.load_lib()
self.placement=self.place_modules()
self.net,self.netclass=self.create_net()
self.write_dsn()
def brd_general(self):
self.brd=dsnwritier.Dsn()
self.layers=[
dsnwritier.Layer('F.Cu'),
dsnwritier.Layer('B.Cu'),
dsnwritier.Layer('F.Mask'),
dsnwritier.Layer('B.Mask')
]
self.parsers= dsnwritier.Parser()
self.rule=dsnwritier.Rule()
clearance=[
dsnwritier.Clearance(200.1),
dsnwritier.Clearance(200.1,'default_smd'),
dsnwritier.Clearance(50,'smd_smd')]
self.rule.clearance=clearance
def load_drawing(self):
"""
create class: bourdry and keepout
from drawing file
"""
dwg=(dsnwritier.load_drawing(self.dwgfile)).load_polygon()
bdata=dwg.pop(self.boundary_inx)
kdata=dwg
keepout=[]
for i in range(len(kdata)):
keep_class=dsnwritier.Keepout(kdata[i])
keepout.append(keep_class)
boundary=dsnwritier.Boundary(bdata)
return boundary,keepout
def load_lib(self):
"""
create class: footprint (image) and padstack
from library path and modules
"""
image=[]
for mod in self.module_list:
img=dsnwritier.Footprint.from_file(self.libpath+mod[0],ref=mod[1])
image.append(img)
padstack=dsnwritier.Padstack.auto_detect(self.libpath+'mpu-9250.kicad_mod')
return image,padstack
def place_modules(self):
placement=[]
for mod in self.module_list:
place=dsnwritier.Placement(name=mod[0],ref1=mod[1],at=mod[2],orientation=mod[3])
placement.append(place)
return placement
def create_net(self):
nets_list=[]
netclass_list=[]
for net in self.netlist:
nets=dsnwritier.Net(net_name=net[0],conn_pins=net[1])
nets_list.append(nets)
for netclass in self.netclass_list:
netclasses=dsnwritier.NetClass(net_class_name=netclass[0],
nets_name=netclass[1],
via_name=netclass[2],
width=netclass[3],
clearance=netclass[4])
netclass_list.append(netclasses)
return nets_list,netclass_list
def write_dsn(self):
self.brd.parser=self.parsers
self.brd.rule=self.rule
self.brd.layers=self.layers
self.brd.boundary=self.boundary
self.brd.keepout=self.keepout
self.brd.image=self.image
self.brd.padstack=self.padstack
self.brd.placement=self.placement
self.brd.net=self.net
self.brd.netclass=self.netclass
self.brd.to_file('paperbot_ee.dsn')
libpath='/home/jingyan/Documents/summer_intern_lemur/roco_electrical/libraries/kicad-ESP8266/ESP8266.pretty/'
dwgfile='/home/jingyan/Documents/summer_intern_lemur/roco_electrical/dsn_line_test.dxf'
a= brd_design(dwgfile,0,libpath)