• 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 SKILL
  3. how do you toggle between enterPoint() and enterBox()

Stats

  • Locked Locked
  • Replies 15
  • Subscribers 143
  • Views 19082
  • 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

how do you toggle between enterPoint() and enterBox()

Adhil
Adhil over 13 years ago

Hi

I am trying to create this align function that functions similarly to that of icstation.

the following describes how the macro is used

1. you select the object that you want to move to align

2. invoke the align function via a bindkey

3. the function prompts you to enter a point which it then uses to select the reference object.

4. complete the action by moving the initially object and aligning it to the reference object.

 how can i make the selection of the reference object be versatile so that i can click to select a reference object or draw a box to select multiple reference objects. i was thinking of a function  that can toggle between enterpoint() or enterbox(), but i dont know how to do this. please help.

thanks

Adhil

  • Cancel
  • dmay
    dmay over 13 years ago

    One way is to use the changeEnterFun() command. You could activate this command with a bindKey or radio button on your form to toggle between enterPoint and enterBox.

    Another way is to define the EF feature of one of your mouse draw-thru keys to do what you want.

    hiSetBindKey("Layout" "<DrawThru3> EF" "myCommand()")

    When you write "myCommand" it can check the result of hiGetCurrentCmd to make sure it only operates when your command is running. You'll need to use the ?cmdName argument to enterPoint and will probably need to use something like finishEnterFun or applyEnterFun.

    There may be other ways to do it as well. Search the Cadence docs for "enterFun" and see what works best.

    Derek

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Adhil
    Adhil over 13 years ago

    this is my code

    procedure(xAlign()

    let((objects obj somepoints refObject shift overallbbox)

    objects = geGetSelSet() ; selects objects to be moved to align

    somepoints = enterPoint(                   ; prompts the user to enter a point which will be used to select the reference object
      ?prompts list("enter the ref object")
      ?doneProc "adhGetSelSet"
      ?initProc "setSelectionMode"
          )
    geAddSelectPoint(hiGetCurrentWindow() nil somepoints) ; selecting the reference object
    refObject = car(last(geGetSelSet()))
    overallbbox = makeInstance('overallbbox ?bBox trBBoxUnion(objects~>bBox))
    println(overallbbox~>bBox)
    shift = getXshift(overallbbox refObject)

    foreach(obj objects
    dbMoveFig(obj geGetEditCellView() list(shift:0 "R0")))
    geDeselectAll()
     
     ))

    procedure(setSelectionMode(win)
    geSetEnterFunctionSelectionMode(win 4)
    )  

    procedure(trBBoxUnion( bBoxList )
    let((llxList llyList urxList uryList minllx minlly maxurx maxury)
    llxList = foreach(mapcar bBox bBoxList xCoord(lowerLeft(bBox)))
    llyList = foreach(mapcar bBox bBoxList yCoord(lowerLeft(bBox)))
    urxList = foreach(mapcar bBox bBoxList xCoord(upperRight(bBox)))
    uryList = foreach(mapcar bBox bBoxList yCoord(upperRight(bBox)))
    minllx = apply('min llxList)
    minlly = apply('min llyList)
    maxurx = apply('max urxList)
    maxury = apply('max uryList)
    list(minllx:minlly maxurx:maxury)
       )
    )

    defclass( overallbbox ()
    (
     (bBox @initarg bBox)
     )
    )

    procedure(getXshift(object ref)
    let((shift objectMidx refMidx)

     objectMidx = (xCoord(lowerLeft(object~>bBox))+xCoord(upperRight(object~>bBox)))/2
            refMidx    = (xCoord(lowerLeft(ref~>bBox))+xCoord(upperRight(ref~>bBox)))/2
    shift = refMidx - objectMidx
    shift  
    )  )

    hiSetBindKey("Layout" "Super<Key>x" "xAlign()")

    how can i tell xAlign() to use enterpoint() (shown in Bold)  when i "click" or use enterBox() when i "click and drag". 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • dmay
    dmay over 13 years ago

    I think you can probably do what you are asking, but I'm beginning to wonder why? First of all, there is a great alignment tool in 6.1.5 called leHiQuickAlign that would do what you want and more. Are you using 6.1? If not, have you tried leHiAlign (in 5.1.41)? Before I try to provide you some help to your question I think you should look into Cadence align features before re-writing an IC Station align, especially since Quick Align lets you pick edges and space by rule etc.

    Second, how does a selected set work better than a single point when you are setting up a reference point for alignment? You are going to have to process that selected set and come up with a single point anyway. What is the benefit of doing that?

    Derek

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Adhil
    Adhil over 13 years ago
    Hi Derek

    I am aware of  lehialign and th leHiQuickAlign, however, LeHiAlign is quite difficult to get around and leHiQuickAlign() can be quite buggy as it does not properly hilight the areas that i want the selected items to align to.

     the icstation align tool is very easy to use. and i love it.
    1. you can partially select a vertice and align it to any object.
    2. you can select multiple objects and it can align the common centre to any reference object.
    3. the whole procedure is quite intuitive.  

    therefore, by recreating the three align modes that i most often use, i.e x center x centre align, y center y centre align and centre centre align, and allocating bind keys to each align function, i can improve my productivity. i feel that  always invoking a form when you want to align something to be very cumbersome, especially when you use only three of the functions.

    the reason why this question was posed is that i want to have the option of aligning the common  centre of a selected group of objects to the common centre of a selected group of reference objects.

    I hope you can help me out

    Adhil
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Adhil
    Adhil over 13 years ago

    ::::::::::::::::::::::::::::::::::: (ref object B)

    ::::::::::::::::::::::::::::::::::: (ref object C)

                                                :::::::::::::::::::::::::::::: (object A)

    1. select object A
    2. press bindkey for "y centre y centre align"
    3. draw selection bbox to select ref object B and C together.
    then

    ::::::::::::::::::::::::::::::::::: (ref object B)
                                                :::::::::::::::::::::::::::::: (object A)
    ::::::::::::::::::::::::::::::::::: (ref object C)

                                               

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • dmay
    dmay over 13 years ago

    Is Quick Align buggy, or it just doesn't let you hilight the common center of the selected objects? I find it very useful and the form is definitely not needed. I agree leHiAlign is cumbersome, but only mentioned it in case you were running 5.1.41 where Quick Align doesn't exist.

    1. You can partially select a vertice and align it to any object using Quick Align
    Partially select the edge, press the quick align bindkey, double click the destination edge
    2. You can almost do this, but you cannot choose the common center. In my experience this is not a problem because there is always an edge I can use for aligning. Select all the objects, press the quick align bindkey, pick the edge in your selection and the destination edge.
    3. Quick Align takes a little practice but is feature rich. Using your right mouse button there are a couple options for setting a veritical or horizontal target axis. You can align all objects individually with a double click and the whole group with a single click. It can see through hierarchy. Seems like you could ask for an enhancement for common center.

    Derek

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • dmay
    dmay over 13 years ago

    Try this:

    procedure(xAlign()
        myAlign("X")
    ) ;proc

    procedure(yAlign()
        myAlign("Y")
    ) ;proc


    procedure(myAlign(dir)
    let((objects obj shift sourceBox refObjects refBox pt)

        objects = geGetSelSet() ; selects objects to be moved to align

        pt = enterPoint(                   ; prompts the user to enter a point which will be used to select the reference object
          ?prompts list("Select the ref object")
          ?addPointProc "myAddPointProc"
          ?initProc "setSelectionMode"
          ?cmdName "xAlign"
        )
        sourceBox = trBBoxUnion(objects~>bBox)

        if(refObjects = setof(x geGetSelSet() !memq(x objects))
            refBox = trBBoxUnion(refObjects~>bBox)
            refBox = list(pt pt)
        )
        if(dir == "X"
            shift = list(getXshift(sourceBox refBox) 0)
            shift = list(0 getYshift(sourceBox refBox))
        )
        foreach(obj objects
          dbMoveFig(obj geGetEditCellView() list(shift "R0"))
        )
        geDeselectAll()
        mapcar('geSelectObject objects)
     
     )
    )

    procedure(myAddPointProc(win pt)
        geAddSelectPoint(hiGetCurrentWindow() nil car(pt)) ; selecting the reference object
    ) ;proc

    procedure(setSelectionMode(@optional (win hiGetCurrentWindow()))
        geSetEnterFunctionSelectionMode(win 4)
    )

    procedure(trBBoxUnion( bBoxList )
      let((llxList llyList urxList uryList minllx minlly maxurx maxury)
        llxList = foreach(mapcar bBox bBoxList xCoord(lowerLeft(bBox)))
        llyList = foreach(mapcar bBox bBoxList yCoord(lowerLeft(bBox)))
        urxList = foreach(mapcar bBox bBoxList xCoord(upperRight(bBox)))
        uryList = foreach(mapcar bBox bBoxList yCoord(upperRight(bBox)))
        minllx = apply('min llxList)
        minlly = apply('min llyList)
        maxurx = apply('max urxList)
        maxury = apply('max uryList)
        list(minllx:minlly maxurx:maxury)
      )
    )

    procedure(getXshift(srcBox refBox)
      let((x1 x2)
        x1 = car(centerBox(srcBox))
        x2 = car(centerBox(refBox))
        x2-x1
      ) ;let
    ) ;proc
    procedure(getYshift(srcBox refBox)
      let((y1 y2)
        y1 = cadr(centerBox(srcBox))
        y2 = cadr(centerBox(refBox))
        y2-y1
      ) ;let
    ) ;proc

    procedure(CreateAlignSet()
      let((pts)
        pts = enterBox( ?prompts list("Select the ref objects"))
        geAddSelectBox(hiGetCurrentWindow() nil pts) ; selecting the reference objects
        cancelEnterFun() ;Cancels the enterPoint that started this whole thing
      ) ;let
    ) ;proc

    ;This is necessary otherwise you'll lose the default functionality
    ;that allows geSingleSelectBox to work during other enterFunctions
    procedure(drawThru1Bk()
        case(hiGetCurrentCmd(hiGetCurrentWindow())
            (("xAlign" "yAlign")
                CreateAlignSet()
            )
            (t
                geSingleSelectBox()
            )
        )
    ) ;proc

    hiSetBindKey("Layout" "<DrawThru1> EF" "drawThru1Bk")
    hiSetBindKey("Layout" "<Key>x" "xAlign()")
    hiSetBindKey("Layout" "<Key>y" "yAlign()")

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Adhil
    Adhil over 13 years ago

    Thank you so much for the code, just a few questions

    1. Why did you define the ?cmdName in enterPoint

    I tested it, the function does not work as intended, you have to select the ref objects and then click again for the objects to align. However, if you define cmdName, then it works. And why did you enter the string "xAlign" as the value for this. 

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • dmay
    dmay over 13 years ago

    The drawThru1Bk function that is defined on the drawThru1 enter function bindkey checks to see what function is running. It only does what you need it to do when the function name matches your command. Otherwise, it runs the command that was originally defined on the drawThru1 bindkey.

    For example, if you have nothing selected and you start the Cadence stretch command, you can select items to stretch using the drawThru1 bindkey. If I had simply replaced the drawThru1 bindkey with a custom command, this functionality would be lost. Now, if you start your enter function using either the x or y bindkeys (for xAlign or yAlign), and then use the drawThru1 bindkey, it will know to do the alignment with the references you select instead of with a single item or point.

    Actually you could tweak the code to use a more generic name than xAlign. I put that in before I modified the code to be able to do a yAlign as well. If you change the cmdName to be "myAlign", then you can change the drawThru1Bk procedure to just check for "myAlign".

    Derek

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Adhil
    Adhil over 13 years ago

    you had defined ?cmdName as "xAlign" in your code, but when i run yAlign, it runs just as well. why is that?

    in a different note.

    can you define bindkeys that can come into effect only when a specific function,for which it is defined, is executing? 

    • 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