• 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 21577
  • 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
Parents
  • 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
Reply
  • 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
Children
No Data

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