Kicad script
unknown
python
2 years ago
1.9 kB
20
Indexable
# execfile("C:\My\Projects\PCB\Heating Table\power_unit.py")
import pcbnew
board = pcbnew.GetBoard()
print board.GetFileName()
def AddBox(center_x, center_y, width, height):
#pos += null_pos
#AddLine(pos - [size[0], 0], pos + [sizep[0], 0])
#AddLine(pos - [size[0], 0])
center_x += null_pos[0]
center_y += null_pos[1]
half_width = width / 2
half_height = height / 2
lines = [
((center_x - half_width, center_y - half_height), (center_x + half_width, center_y - half_height)),
((center_x + half_width, center_y - half_height), (center_x + half_width, center_y + half_height)),
((center_x + half_width, center_y + half_height), (center_x - half_width, center_y + half_height)),
((center_x - half_width, center_y + half_height), (center_x - half_width, center_y - half_height))
]
for start, end in lines:
AddLine(start[0], start[1], end[0], end[1])
def AddLine(from_x, from_y, to_x, to_y):
line = pcbnew.DRAWSEGMENT(board)
line.SetShape(pcbnew.S_SEGMENT)
line.SetLayer(pcbnew.Edge_Cuts)
line.SetStart(pcbnew.wxPointMM(from_x, from_y))
line.SetEnd(pcbnew.wxPointMM(to_x, to_y))
line.SetWidth(pcbnew.FromMM(0.1))
board.Add(line) #Add line
def AddHole(pos_x, pos_y):
pos_x += null_pos[0]
pos_y += null_pos[1]
hole = pcbnew.VIA(board)
hole.SetPosition(pcbnew.wxPointMM(pos_x, pos_y))
hole.SetDrill(pcbnew.FromMM(1.0))
hole.SetWidth(pcbnew.FromMM(1.5))
board.Add(hole)
#Default coordinate
null_pos = [15, 15]
#Add Back. 20x20 + holes
AddBox(10, 10, 20, 20)
AddBox(100, 10, 20, 20)
AddHole(4, 14)
AddHole(14, 4)
AddHole(110 - 4, 14)
AddHole(110 - 14, 4)
#Add Step down XL4015
AddBox(55, 15, 51, 26)
# !!! Add holes
#Add Power In
AddBox(100, 35, 20, 20)
# !!! Add holes
#Add USB Out
AddBox(67 / 2, 45, 67, 19)
#Add Front panel
AddBox(55, 80, 110, 40)
# !!! Add holes
Refresh()Editor is loading...
Leave a Comment