How to import positions?

I have 24 LED’s I want to lay out in a circle (microscope ring light)

By far the easiest way I can think of to do this is use something to generate teh x,y,rot parameters for each one ala the .pos file. Is there a way to easily import this back into the pcb file?


See this thread


I haven’t tested it, but this snippet of my new script should do the job for placing the Modules

import pcbnew
import collections
import math

pcb = pcbnew.GetBoard()

#calc rotation angle (rad) with Position in Clock: float -> float
def calcRadAngleFromClockPosition(clockPosition):
	return math.pi/12*(clockPosition%24)
#calc ratation angle (deg) with Position: float -> float 
def calcDegAngleFromClockPosition(clockPosition):
	return math.degrees(calcRadAngleFromClockPosition(clockPosition))
#calc the Position(s) with the Radius and an Angle: float, float -> float/float/wxPoint
def calcXLocationFromClockPositionMM(radius, clockPosition):
	return (math.sin(calcRadAngleFromClockPosition(clockPosition))*radius)
def calcYLocationFromClockPositionMM(radius, clockPosition):
	return (-math.cos(calcRadAngleFromClockPosition(clockPosition))*radius)
def calcXYLocationFromClockPositionWxPoint(radius, clockPosition):
	return pcbnew.wxPointMM(calcXLocationFromClockPositionMM(radius,clockPosition),calcYLocationFromClockPositionMM(radius,clockPosition))

def findModules():
	modules = {}
	for mod in pcb.GetModules():
		referenceString = mod.GetReference().encode('utf-8')
		print "Found Module: %s" %(referenceString)
	#Order The Dictionary
	return collections.OrderedDict(sorted(modules.items(), key=lambda t: t[0]))
def getSecondModules(modules_dict):
	odict = collections.OrderedDict()
	for key, value in modules_dict.items():
            #Insert here your LED Annotation
		if(key[0] == "D" and key[1] in range(1,24+1)):
	return odict

def setPositionSecondRing(modulesSeconds, radiusSeconds):
	for key, value in modulesSeconds.items():
		value.SetPosition(calcXYLocationFromClockPositionWxPoint(radiusSeconds, key[1]-1))
		print 'Placed: Second %s at %s with rot %s' % (key[0]+str(key[1]), str(value.GetPosition()), str(value.GetOrientation()))

def main():
	Modules = findModules()
	setPositionSecondRing(getSecondModules(Modules), 40)

if __name__ == '__main__':

I don’t know how you will route it but keep in mind to use module.Pads() to get the pads and pad.GetPosition() to get your start and End Points and pad.GetNetCode() for the netCode. This will be help you with the Tracks. And one Last snippet:

def addTrack(startLocation, stopLocation, netCode, layer):
	t = pcbnew.TRACK(pcb)
	return t