• 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 to Retrieve the value of dX and dY in the current w...

Stats

  • Locked Locked
  • Replies 18
  • Subscribers 143
  • Views 22006
  • 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 to Retrieve the value of dX and dY in the current window

ClintMeyer
ClintMeyer over 14 years ago

I would like to create a script that will automatically move whatever I have selected in a layout window by the same amount as the last move.  The last move/copy/stretch relative distance is displayed in the layout window as dX and dY (standing for delta X and delta Y i presume).  Is there a skill function that returns that value?  I looked under the hiGetCurrentWindow() and it was not there.

 Thanks for any help

 Clint

 

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 14 years ago

    Clint,

    This shows how to do it:

     procedure(abGetDxDy(@optional (win hiGetCurrentWindow()))
     let((refPoint curPoint delta)
      refPoint=leGetRefPoint(geGetEditCellView(win))
      curPoint=hiGetCommandPoint(win)
      when(refPoint && curPoint
        delta=mapcar('difference curPoint refPoint)
      )
      printf("dx=%L dy=%L\n" xCoord(delta) yCoord(delta))
     )
    )

    ; change the bindkey to what you want
    hiSetBindKey("Layout" "<Key>d" "abGetDxDy()")

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • ClintMeyer
    ClintMeyer over 14 years ago

    DELETED DOUBLE POST

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • ClintMeyer
    ClintMeyer over 14 years ago

    Hey Andrew

     Thanks for the procedure.  Unfortunately, I was not fully understanding how Dx and Dy work.  Let me give you some background on what I am looking for.

     Back in 1998 when I worked for IBM, they had in house CAD tools.  The layout editor (GYM) had as a standard feature the ability to store the Dx/Dy for the previous data manipulation event (whether move/copy/stretch/etc..).  Then a command could be issued that would move the current selected set of objects by the previous Dx Dy in the positive or negative direction.  This was a surprisingly handy data manipulation command that was used more often that it would seem. 

     Your abGetDxDy.il gets the data but to use that skill code, I would have to do the following.

     1) select data and initiate the move command (order is only important if you want to keep the set of items selected after you finish the move command and whether you want "repeat commands" to work)

    2) click with the left mouse button where you want to reference your move from (depends on whether the user uses inFix or not, but lets save that debate for another day LOL)

    3) move your mouse to the new location for the move

    4) inititate the abGetDxDy() procedure and store the results in a variable

    5) left click with the mouse to set the new location for the selected set

    Now I can recall the variable with DxDy stored to use as input into a relative move command.  That is the simple part. 

    What I would really like is a way to grab the relative location of the cursor (your abGetDxDy) at the same moment as when I click to set the new location (step 5).  My pea sized brain imagines that one would need to build new procedure that wraps around leHiMove/Stretch/Copy/etc.... and uses those new procedures instead of leHiMove/Stretch/Copy/etc....

     If you can show me one, i can figure out the others.  I would be really interested to see how you do it (copying is the best way for me to learn). 

    I have a feeling that this has something to do with enter function, which I still dont have a complete understanding of.

     Anyway, thanks again for your help!!

     Clint

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 14 years ago

    Hi Clint,

    This appears to do the trick:

     procedure(abGetDxDy(@optional (win hiGetCurrentWindow()))
     let((refPoint curPoint)
      refPoint=leGetRefPoint(geGetEditCellView(win))
      curPoint=hiGetCommandPoint(win)
      when(refPoint && curPoint && member(hiGetCurrentCmd(win) '("Move" "Copy"))
        abGetDxDy.lastDelta=mapcar('difference curPoint refPoint)
      )
     )
    )

    hiSetBindKey("Layout" "<Btn1down>EF" "abGetDxDy() mouseAddPt(t)")

    It redefines the left mouse button (in enter function mode) to record the last delta when in Move or Copy commands. You can then access the last delta outside by using abGetDxDy.lastDelta

    You would need to extend the list of commands in the member() statement to include those that you want to cover.

    Let me know how you get on!

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • ClintMeyer
    ClintMeyer over 14 years ago

    Andrew

     Brilliant!!!  I really like how concise the code is.  I can start to understand it.  It is so close to what I need I can smell it.  I found 2 things

    1) I had to remove the (t) from MouseAddPt() in the bindkey as no argument is needed.

    2) This one is a bit trickier.  Around 1/2 of the time when a layout designer is manipulating data, the SnapMode will be Orthogonal so the mouse cursor accuracy is only sensitive to 1 axis rather than 2.  This saves the layout designer time because when he is certain that the final location is orthogonal to the reference click, the VLE "cursor" (either a box or a dotted line cross shape) will be orthogonal to the reference point .  This "VLE cursor" will almost always be different than the mouse cursor when moving/copying/stretching with SnapMode set to Orthogonal. The hiGetCommandPoint() returns the position of the mouse cursor not the VLE cursor.  I looked through Finder and tried as many cursor type commands as I could find to see if one would display the VLE cursor position upon click, but they all seemed to use the mouse cursor.  I tried hiGetDbuPoint and others.

    Thanks again for the help.

     Clint 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • ClintMeyer
    ClintMeyer over 14 years ago

    DELETED DOUBLE POST

    Some of my posts were getting caught in a filter.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 14 years ago
    Hi Clint,

    I'll check in the morning - should be able to refine it to do what you want (admittedly I did very little testing as I'm rather short of time at the moment).

    Regards,

    Andrew
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • dmay
    dmay over 14 years ago

    One way would be to replace:

    abGetDxDy.lastDelta=mapcar('difference curPoint refPoint)

    with a conditional that checks the snap value and then sets the delta accordingly. For anyAngle, the current code works. For orthogonal, use the larger of the dx and dy and set the other to 0. For diagonal, it is a little trickier. It looks like the delta is only in the x dir when the dx is more than twice dy. The dx and dy would be the same when dx > 0 and dy > 0 and dx is not more than twice dy or less than half dy. You can experiment with this in your window.

    case(hiGetCurrentWindow()~>snapMode
      ("anyAngle" 
        abGetDxDy.lastDelta=mapcar('difference curPoint refPoint)
      )
      ("orthogonal"
        delta = mapcar('difference curPoint refPoint)
        if(car(delta) >= cadr(delta)
          abGetDxDy.lastDelta(car(delta) 0.0)
          abGetDxDy.lastDelta(0.0 cadr(delta))
        )
      )
      ("diagonal"
        println("more work is needed here")
      )
      (t
        println(strcat(hiGetCurrentWindow()~>snapMode " not supported"))
      )
    )

    Or, maybe Andrew has a simpler solution. ;-)

    Derek

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • cessej
    cessej over 14 years ago

    I changed the code because it doesn't work correctly from the beginning.

     procedure(abGetDxDy(@optional (win hiGetCurrentWindow()))
      ;gets object's bbox after enterpoint
      abGetDxDy.refPoint=append(abGetDxDy.refPoint list(car(getBbox(geGetSelectedSet()))))
      ;recording the last form
      if(hiGetCurrentCmd(win) then abGetDxDy.lastForm=hiGetCurrentCmd(win))
      ;gets delta if from Move or Copy form
      ;only gets if enterfunc are all finish
      if(member(abGetDxDy.lastForm '("Move" "Copy"))  && !hiGetCurrentCmd(win) then
        ;for dbCopyShape or dbCopyMove
        abGetDxDy.lastDelta=mapcar('difference car(last(abGetDxDy.refPoint)) car(abGetDxDy.refPoint))
        ;for geCopySelSet
        abGetDxDy.firstPoint=car(abGetDxDy.refPoint)
        abGetDxDy.lastPoint=car(last(abGetDxDy.refPoint))
        ;reset
        abGetDxDy.refPoint=nil
        abGetDxDy.lastForm=nil
     )
    )

    hiSetBindKey("Layout" "<Btn1down>EF" "mouseAddPt(t) abGetDxDy()")

     

    procedure(getBbox(@optional objects "l")

      let( (lx rx ly uy)

       unless(objects && forall(obj objects dbobjectp(obj))
          objects = geGetSelectedSet()
        ); unless

        when(objects
          lx = xCoord(lowerLeft(car(objects)~>bBox))
          rx = xCoord(upperRight(car(objects)~>bBox))
          ly = yCoord(lowerLeft(car(objects)~>bBox))
          uy = yCoord(upperRight(car(objects)~>bBox))

          foreach(obj objects
            lx = min(lx xCoord(lowerLeft(obj~>bBox)))
            ly = min(ly yCoord(lowerLeft(obj~>bBox)))
            uy = max(uy yCoord(upperRight(obj~>bBox)))
            rx = max(rx xCoord(upperRight(obj~>bBox)))
          ); foreach

          list(list(lx ly) list(rx uy))

        ); when
      ); let
    ); procedure getBbox

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 14 years ago

    Not sure why cessej rewrote it (it's not clear to me what the original problem he/she was trying to resolve).

    Anyway, I've dug around a bit and haven't yet found a way of getting the "snapped" point. Looking at geAdjustPoint, the documentation suggests that this ought to work, but I believe that despite the documentation, it seems to always assume "Any Angle" as the snap mode. In practice it would probably need to know whether the create or edit snap mode was in place, but that's not it.

    Ideally there would be an API to get the snapped cursor location; I can't find one though. Otherwise Derek's approach is probably the only alternative. 

    I'll ask R&D.

    Note the argument to mouseAddPt() is in the IC615 bindkeys; it's not there before. I don't think it's absolutely essential though - effectively it allows the application to do mfg snapping or something like that.

    Regards,

    Andrew.

    • 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