• 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. Custom IC Design
  3. Sort function to sort the paths selected using the bbox...

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 125
  • Views 10647
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Sort function to sort the paths selected using the bbox or beginpt or end pt

kumargbn
kumargbn over 4 years ago

Hi Everyone.

I am writing a code to join two bus kines i.e  horizontal and vertical.

I'm not able to find a way to  to sort the path list with the bBox or Begin Pt oor End Pt. sometime teh selected order is random

Please let me know how to sort a path list using bbox or begin pt or end pt.

Thanks,

Nirmal.

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 4 years ago

    Hi Nirmal,

    The question really falls down to how would you determine the order? If you have a list of objects, you can use the sort() function with the second argument being a function to compare two objects to determine whether one is less than the other - what "less than" means when comparing two bounding boxes is rather open to interpretation since you have four numbers that come into the equation.

    Assuming that you have a list of pathSegs (rather than paths), then something like this would work (I made this sort based on the beginPt, first point in a point list or lowerLeft of the bounding box):

    procedure(CCFcompareBeginPt(a b)
      let((aPt bPt)
        aPt=a~>beginPt || car(a~>points) || lowerLeft(a~>bBox)
        bPt=b~>beginPt || car(b~>points) || lowerLeft(b~>bBox)
        ; check that either x is less, or if x equal, y is less
        cond(
          (!aPt || !bPt nil) ; check we have a point first
          (xCoord(aPt)<xCoord(bPt) t)
          (xCoord(aPt)==xCoord(bPt) && yCoord(aPt)<yCoord(bPt) t)
          (t nil)
        )
      )
    )
    

    Then you can use (say the objects were selected):

    sortedObjs=sort(geGetSelSet() 'CCFcompareBeginPt)

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • kumargbn
    kumargbn over 4 years ago in reply to Andrew Beckett

    Hi Andrew,

    This works great. Thank you very much.

    Regards,

    Nirmal.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

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