• 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. Setting snap grid spacings

Stats

  • Locked Locked
  • Replies 6
  • Subscribers 127
  • Views 21576
  • 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

Setting snap grid spacings

J Wilwert
J Wilwert over 16 years ago

Hi,

I am using a skill function to redefine my X and Y snap spacings - because using "e" and filling in the form is too cumbersome! 

So, I define the variables xsnap and ysnap, and then:

                hiGetCurrentWindow()~>xSnapSpacing = int( xsnap )
                hiGetCurrentWindow()~>ySnapSpacing = int( ysnap )

Using skill, is there a better way?

THANKS,

John Wilwert 

  • Cancel
  • Jim McMahon
    Jim McMahon over 16 years ago

    Hi John

    I believe this is the best way. Are you experiencing a problem with this approach?

    I typically set several bindkeys to switch between different common snap settings. Here is some example skill. Note, this sets the x and y snap spacings to be the same...

     hiSetBindKey("Layout" "<Key>1" "jmSetSnapSpacing(envGetVal( \"layout\" \"xSnapSpacing\"))" )  ;;<-- restore default snap spacing
            hiSetBindKey("Layout" "<Key>2" "jmSetSnapSpacing(0.25)" )
            hiSetBindKey("Layout" "<Key>3" "jmSetSnapSpacing(0.5)" )
            hiSetBindKey("Layout" "<Key>4" "jmSetSnapSpacing(1.0)" )
            hiSetBindKey("Layout" "<Key>5" "jmSetSnapSpacing(5.0)" )
            hiSetBindKey("Layout" "<Key>6" "jmSetSnapSpacing(10.0)" )

     procedure( jmSetSnapSpacing( snap @optional window "ng" )
         unless( window
             window = hiGetCurrentWindow()
         )
         window->xSnapSpacing = snap
         window->ySnapSpacing = snap

    )

     

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • J Wilwert
    J Wilwert over 16 years ago

    Thanks, Jim.  I was having other issues in Cadence and they somewhat pointed to this skill script.  So, I was curious to learn if there was a better way to perform this task.  There still could be other issues with the skill script, however, this does put this item to rest.

    Again, THANKS!

    John Wilwert 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Sheppy
    Sheppy over 9 years ago

    Hi John and Jim,

    Very late response, however, your hiGetCurrentWindow() did the trick for me. I needed that to write a small piece of code to quickly toggle between 2 grid settings (toggle between fine and coarse grid, which can be set on the fly...). This is my code:


    ;;; Include the following in the cdsinit file or the file where you set all bind keys:
    hiSetBindKey( "Layout"       "Ctrl<Key>G" "LAYEDIT_ToggleFineCoarseGrid( hiGetCurrentWindow() )")
    hiSetBindKey( "Layout" "Ctrl Shift<Key>G" "LAYEDIT_ToggleFineCoarseGridForm()")
    ;;; Or use any other bindkey combination that suits you...

    ;;; The following global variables must be set as well:
    dbGrid           = 0.01
    LAYEDIT_FineSnapGrid   = dbGrid

    LAYEDIT_CoarseSnapGrid = 10.0

    procedure( LAYEDIT_ToggleFineCoarseGrid( windowId )
        let( ( ( currentGrid 0.01 )
               ( newGrid 10.0 )
               ( windowNumber 1 ) )
            
            unless( windowId
                windowId = hiGetCurrentWindow()
            ) ;;; end of unless
                   
            currentGrid  = windowId~>xSnapSpacing

            newGrid      = LAYEDIT_FineSnapGrid
            windowNumber = cadr( parseString( sprintf( nil "%L" windowId ) ":" ) )
            
            when( currentGrid == newGrid
                newGrid  = LAYEDIT_CoarseSnapGrid
            ) ;;; end of when
            
            when( newGrid
                hiGetCurrentWindow()~>xSnapSpacing = newGrid
                hiGetCurrentWindow()~>ySnapSpacing = newGrid
                printf( "Layout editor window %s snap grid set to %L.\n" windowNumber newGrid )
            ) ;;; end of when
            
        ) ;;; end of let
    ) ;;; end of procedure LAYEDIT_ToggleFineCoarseGrid

    procedure( LAYEDIT_ToggleFineCoarseGridForm()
        let( ( fineSnapGridField coarseSnapGridField formFieldList LAYEDIT_ToggleFineCoarseGridForm )
            
            ;;;;;;;;;;;;;;;;;;;;;;
            ;;; Creating the form-fields...
            fineSnapGridField = hiCreateFloatField(
                ?name       'fineSnapGridField
                ?prompt     "Fine Snap Grid (um):"
                ?value      LAYEDIT_FineSnapGrid
                ?defValue   LAYEDIT_FineSnapGrid
                ?callback   "LAYEDIT_ToggleFineCoarseGridFormCB( 'fine )"
                ?acceptNil  nil
                ?editable   t
                ?enabled    t
                ?invisible  nil
                )

            coarseSnapGridField = hiCreateFloatField(
                ?name       'coarseSnapGridField
                ?prompt     "Coarse Snap Grid (um):"
                ?value      LAYEDIT_CoarseSnapGrid
                ?defValue   LAYEDIT_CoarseSnapGrid
                ?callback   "LAYEDIT_ToggleFineCoarseGridFormCB( 'coarse )"
                ?acceptNil  nil
                ?editable   t
                ?enabled    t
                ?invisible  nil
                )
            
            ;;;;;;;;;;;;;;;;;;;;;;
            ;;; Constructing the list of form-fields...
            formFieldList = list(
                list( fineSnapGridField        0:0    300:35    200 )
                list( coarseSnapGridField    0:35    300:35    200 )
            ) ;;; end of field-list
            
            ;;;;;;;;;;;;;;;;;;;;;;
            ;;; Creating the form
            LAYEDIT_ToggleFineCoarseGridForm = hiCreateAppForm(
                ?name            'LAYEDIT_ToggleFineCoarseGridForm
                ?formTitle       "Set Layout Editor Snap Grid"
                ?callback        "LAYEDIT_ToggleFineCoarseGridFormCB( 'okApply )"
                ?fields          formFieldList
                ?buttonLayout    list(
                                     'OKCancelApply
                                 ) ;;; end of ?buttonLayout
                ?buttonDisabled  list( 'Help )
                ?unmapAfterCB    t
                ?initialSize     400:100
                ) ;;; end hiCreateAppForm
                
            ;;;;;;;;;;;;;;;;;;;;;;
            ;;; Displaying the form
            ;;; The -1:-1 centres the form around the current mouse pointer location
            hiDisplayForm( LAYEDIT_ToggleFineCoarseGridForm -1:-1 )

            
        ) ;;; end of let
    ) ;;; end of procedure LAYEDIT_ToggleFineCoarseGridForm

    procedure( LAYEDIT_ToggleFineCoarseGridFormCB( switch )
        let( ( )
            ;;; The value entered in the fields for coarse and fine must not be smaller than the database grid.
            ;;; That is being checked here, and when the OK or APPLY button is pressed,
            ;;; the entered values must be stored in the global variables
            case( switch

                ( 'fine
                    when( LAYEDIT_ToggleFineCoarseGridForm->fineSnapGridField->value < dbGrid
                        LAYEDIT_ToggleFineCoarseGridForm->fineSnapGridField->value = dbGrid
                    ) ;;; end of when
                )
                ( 'coarse
                    when( LAYEDIT_ToggleFineCoarseGridForm->coarseSnapGridField->value < dbGrid
                        LAYEDIT_ToggleFineCoarseGridForm->coarseSnapGridField->value = dbGrid
                    ) ;;; end of when
                )
                ( 'okApply
                    LAYEDIT_FineSnapGrid   = LAYEDIT_ToggleFineCoarseGridForm->fineSnapGridField->value
                    LAYEDIT_CoarseSnapGrid = LAYEDIT_ToggleFineCoarseGridForm->coarseSnapGridField->value
                )
            ) ;;; end of case switch
        ) ;;; end of let
    ) ;;; end of procedure LAYEDIT_ToggleFineCoarseGridFormCB


    I hope this is of any halp to anyone.

    Kind regards,

    Sjoerd

    edit: changed "le" in procedure/variable name to "LAYEDIT_" per request of Andrew (see below).

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

    Hi Sjoerd,

    I would strongly recommend that you change the prefix used in your code. The general suggestion is that customers use code with an uppercase prefix to avoid clashing with anything that Cadence writes. In your case you've used the "le" prefix which is reserved for the layout editor - if we were to write functions with the same name because we assume they're using our prefix, you'd have a problem.

    Also, it's misleading - anyone who sees this code will assume it came from Cadence.

    Perhaps you wouldn't mind correcting that and editing your previous post to update the code?

    Kind Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Sheppy
    Sheppy over 9 years ago

    Hi Andrew,

    You're absolutely right, sorry, my sincere apologies.

    I have changed the code on our systems, however, I am unable to change the code here on the forum. Is it possible for me to edit the code in the original post?

    Once again, sorry for this mistake.

    With kind regards,

    Sjoerd

    edit: found the edit button, code changed.

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

    Thanks Sjoerd - I was hoping you'd see an edit button. I suddenly wondered if only I get it as a moderator...

    Anyway, thanks for fixing it!

    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