Skip to content

Instantly share code, notes, and snippets.

@kylemanna
Last active August 5, 2017 06:07
Show Gist options
  • Save kylemanna/cfe44f645aa347589bd2f30832ddd990 to your computer and use it in GitHub Desktop.
Save kylemanna/cfe44f645aa347589bd2f30832ddd990 to your computer and use it in GitHub Desktop.
Tool to generate Kicad XYRS pick and place data from a board file, now lives @ https://github.com/kylemanna/kicad-utils
#!/usr/bin/env python2
#
# Generate a XYRS file
#
# Simple script, more elaborate script has a new home:
# https://github.com/kylemanna/kicad-utils
#
import pcbnew
import sys
board = pcbnew.LoadBoard(sys.argv[1])
MODULE_ATTR_NORMAL = 0
MODULE_ATTR_NORMAL_INSERT = 1
MODULE_ATTR_VIRTUAL = 2
for module in board.GetModules():
if (module.GetAttributes() == MODULE_ATTR_NORMAL_INSERT):
(pos_x, pos_y) = module.GetPosition()
side = 'top'
if module.IsFlipped():
side = 'bottom'
data = {'Reference': module.GetReference(),
'PosX': pos_x/1000000.0,
'PosY': pos_y/1000000.0,
'Rotation': module.GetOrientation()/10.0,
'Side': side
}
print("{0[Reference]} {0[PosX]}, {0[PosY]}, {0[Rotation]}, {0[Side]}".format(data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment