
import pcbnew
board = pcbnew.GetBoard()
mods = board.GetModules()

for i in mods:
    ref = i.GetReference()
    if not ref.startswith('D'):
        continue
    k_ref = "K" + ref[1:]
    k = board.FindModuleByReference(k_ref)
    print k_ref, k
    k_center = k.GetCenter()
    d_center = pcbnew.wxPoint(k_center.x - 3808700, k_center.y - 6200000)
    i.SetPosition(d_center)
    i.SetOrientation(2700)
    print k_ref, ref, d_center
    
