skill code for placing components around circle (polar placement...
PCB SKILL Forums
skill code for placing components around circle (polar placement)
over 3 years ago
Anyone have skill code for placing components around circle (polar placement) ?
over 3 years ago
Try this code:
defun( CircularPlace ()
let((mypopup, syms, symbols, (continue t), centrePt, radiusStr, radius, angle, angleStr, pt, symAngle)
; Create the RMB popup options for Done and Cancel:
mypopup = axlUIPopupDefine(nil (list (list "Done" 'axlFinishEnterFun), (list "Cancel" "axlCancelEnterFun(), continue = nil")))
; Select and highlight the symbols to arrange:
axlSetFindFilter(?enabled '("noall", "SYMBOLS"), ?onButtons '("SYMBOLS"))
while(axlSelect(?prompt "Select symbols..."); will only continue if one or more objects are selected.
syms = axlGetSelSet()
symbols = append(symbols, syms)
symbols = unique(symbols); We don't want duplicates
and(; Stop if user cancels or anything fails
continue; Don't continue if the user cancelled
symbols; Only continue if at least one symbol was selected
centrePt = axlEnterPoint(?prompts "Select the circle centre", ?gridSnap t); Request the circle centre point
radiusStr = axlUIPrompt("Enter the radius", "200"); Request the circle radius (a string)
radius = readstring(radiusStr); Convert the string to a number
numberp(radius); Ensure that the radius is actually a number
angle = 360.0 / length(symbols); Calculate the expected delta angle between symbols
angleStr = axlUIPrompt("Enter the angle", sprintf(nil, "%L", angle)); Allow the user to select an angle
angle = readstring(angleStr); Convert the string to a number
numberp(angle); Ensure that the angle is actually a number
angle = float(angle); The angle needs to be real for axlGeoRotatePt.
pt = list(car(centrePt) + radius, cadr(centrePt)); This is the starting point.
symAngle = 0.0; This is the starting angle. *** Change to 90.0 if the component requires it ***
pt = axlGeoRotatePt(angle, pt, centrePt); Calculate the next point
symAngle = symAngle + angle; Calculate the next symbol angle
axlTransformObject(sym, ?move axlMXYSub(pt, sym ->xy), ?angle symAngle - sym ->rotation); Move the symbol.
The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full