• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Allegro X PCB Editor
  3. skill code for placing components around circle (polar placement...

Stats

  • Replies 18
  • Subscribers 162
  • Views 25859
  • Members are here 0
More Content

skill code for placing components around circle (polar placement)

KARPCB
KARPCB over 11 years ago

 Hi ,

 

Anyone have  skill code for placing components around circle (polar placement) ?

 

Thanks,

Karthik

  • Cancel
  • Sign in to reply
Parents
  • eDave
    eDave over 11 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")))
    axlUIPopupSet(mypopup)
    ; 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)
    axlClearSelSet()
    axlHighlightObject(syms)
    )
    symbols = unique(symbols); We don't want duplicates
    axlDehighlightObject(symbols)
    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 ***
    foreach(sym, symbols
    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.
    )
    )
    ))
     
    Dave 
     
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • eDave
    eDave over 11 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")))
    axlUIPopupSet(mypopup)
    ; 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)
    axlClearSelSet()
    axlHighlightObject(syms)
    )
    symbols = unique(symbols); We don't want duplicates
    axlDehighlightObject(symbols)
    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 ***
    foreach(sym, symbols
    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.
    )
    )
    ))
     
    Dave 
     
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
Cadence Guidelines

Community Guidelines

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 Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information