View Single Post
And for radially even spacing of the magnets (on a circle shape, for example) you could calculate the coordinates:

Code:
property plngMagnets : 16
property prStartDegrees : 360 / 32

on run
	set lstMagnets to RadialMagnets(plngMagnets, prStartDegrees)
	tell application id "OGfl"
		tell front window
			repeat with oGraphic in (selection) as list
				if class of oGraphic = shape then set magnets of oGraphic to lstMagnets
			end repeat
		end tell
	end tell
end run

on RadialMagnets(lngN, rStartDegree)
	if lngN < 1 then return {}
	
	set lstMagnets to {}
	set rTheta to rStartDegree
	set rDelta to 360 / lngN
	
	repeat with i from 1 to lngN
		set end of lstMagnets to {sin(rTheta), -(cos(rTheta))}
		set rTheta to rTheta + rDelta
	end repeat
	return lstMagnets
end RadialMagnets


on sin(rDegrees)
	(do shell script "echo 's(" & (rDegrees / 180) * pi & ")' | bc -l") as number
end sin

on cos(rDegrees)
	(do shell script "echo 'c(" & (rDegrees / 180) * pi & ")' | bc -l") as number
end cos

Last edited by RobTrew; 2012-02-19 at 12:21 PM.. Reason: Made the code slower but more legible ... :-)