• 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 create a form that lists all shapes/instances in...

Stats

  • Locked Locked
  • Replies 4
  • Subscribers 143
  • Views 3349
  • 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 create a form that lists all shapes/instances in the layout?

Sharif H N
Sharif H N over 9 years ago

Hi,


I would like to create form[Not sure if I'm using the right word] that lists all  shapes/instances in the layout and I want to select shapes in the layout from that list. Any help in this regard will be appreciated.

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 9 years ago

    A couple of bits of code you could use as a starting point. This first one is a generic tree form example, which can be used with:

    abTreeExample(geGetEditCellView()~>shapes)

    Regards,

    Andrew

    /* abTreeExample.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Feb 16, 2010 
    Modified   
    By         
    
    ***************************************************
    
    SCCS Info: @(#) abTreeExample.il 11/12/14.15:43:40 1.2
    
    */
    
    /****************************************************************
    *                                                               *
    *                 (abCreateTreeExample shapes)                  *
    *                                                               *
    *    Given a list of db objects (e.g. shapes) create a tree     *
    * representation of the data in a form called abTreeExampleForm *
    *                                                               *
    ****************************************************************/
    
    (defun abCreateTreeExample (shapes)
      (let (tree subTreeLookup (shapeNum 1) objType bBox treeItem
                 select delete info subTree treeField)
        ;--------------------------------------------------------------------
        ; Create a table to store the trees for each type of object encountered
        ;--------------------------------------------------------------------
        (setq subTreeLookup (makeTable 'subTreeLookup nil))
        ;--------------------------------------------------------------------
        ; Then traverse the shapes (doesn't have to just be shapes - any db object
        ; will do) and add an item for each
        ;--------------------------------------------------------------------
        (foreach shape shapes
                 (setq objType (dbGetq shape objType))
                 ;-----------------------------------------------------------
                 ; Find the existing tree, or create a new one
                 ;-----------------------------------------------------------
                 (setq subTree 
                       (or 
                         (arrayref subTreeLookup objType)
                         (setarray subTreeLookup objType
                                   (hiCreateTree (concat objType 'tree))
                                   )
                         ))
                 (setq bBox (dbGetq shape bBox))
                 ;-----------------------------------------------------------
                 ; Add an item to the appropriate shape tree for this
                 ; object
                 ;-----------------------------------------------------------
                 (hiTreeAppendItem
                   subTree
                   (hiCreateTreeItem (concat 'shape shapeNum)
                                     (list (sprintf nil "Shape %d" shapeNum)
                                           (dbGetq shape layerName)
                                           (dbGetq shape purpose)
                                           (xCoord (lowerLeft bBox))
                                           (yCoord (lowerLeft bBox))
                                           (xCoord (upperRight bBox))
                                           (yCoord (upperRight bBox))
                                           )
                                     )
                   )
                 (postincrement shapeNum)
                 )
        ;--------------------------------------------------------------------
        ; Now create the main tree
        ;--------------------------------------------------------------------
        (setq tree (hiCreateTree 'shapes))
        (foreach shapeType subTreeLookup
                 (setq treeItem
                   (hiCreateTreeItem 
                     (concat shapeType)
                     (list shapeType)
                     )
                   )
                 (hiTreeAppendItem shapes treeItem)
                 (hiItemInsertTree treeItem (arrayref subTreeLookup shapeType))
                 )
        ;--------------------------------------------------------------------
        ; And the tree field itself
        ;--------------------------------------------------------------------
        (setq treeField
              (hiCreateTreeTable
                ?name 'shapeTree
                ?title "Shapes"
                ?titleAlignment 'center
                ?headers (list
                           (list "Type" 125 'left 'string t)
                           (list "Layer" 80 'left 'string t)
                           (list "Purpose" 80 'left 'string t)
                           (list "LLX" 80 'left 'float t)
                           (list "LLY" 80 'left 'float t)
                           (list "URX" 80 'left 'float t)
                           (list "URY" 80 'left 'float t)
                           )
                ?choice tree
                )
              )
        ;--------------------------------------------------------------------
        ; Now create the context menu
        ;--------------------------------------------------------------------
        (setq select
              (hiCreateMenuItem
                ?name 'select
                ?itemText "Select"
                )
              )
        (setq delete
              (hiCreateMenuItem
                ?name 'delete
                ?itemText "Delete"
                )
              )
        (setq info
              (hiCreateMenuItem
                ?name 'info
                ?itemText "Info"
                )
              )
        (hiCreateMenu
          'abTreeExampleMenu
          "Tree Item"
          (list select delete info)
          )
        ;--------------------------------------------------------------------
        ; Attach the context menu to the field
        ;--------------------------------------------------------------------
        (putpropq treeField abTreeExampleMenu hiContextMenu)
        (putpropq treeField 'abTreeExampleMenuContextCB hiShowContextMenuCallback)
        ;--------------------------------------------------------------------
        ; Then finally create the form
        ;--------------------------------------------------------------------
        (hiCreateAppForm
          ?name 'abTreeExampleForm
          ?formTitle "Tree Example"
          ?fields (list
                    (list treeField 5:5 610:400 20)
                    )
          ?initialSize 620:420
          ?attachmentList (list
                            hicLeftPositionSet|hicRightPositionSet|
                            hicTopPositionSet|hicBottomPositionSet
                            )
          ) ; hiCreateAppForm
        ) ; let
      ) ; defun abCreateTreeExampleForm
    
    /***************************************************************
    *                                                              *
    *      (abTreeExampleMenuContextCB menu form field item)       *
    *                                                              *
    *                Callback for the context menu                 *
    *                                                              *
    ***************************************************************/
    
    (defun abTreeExampleMenuContextCB (menu form field item)
      (printf "Context Menu called: %L %L %L %L\n"
              menu form field item)
      (printf "Value of tree is %L\n"
              (getq (get form field) value))
      )
    
    /***************************************************************
    *                                                              *
    *                   (abTreeExample objects)                    *
    *                                                              *
    *                       Main entry point                       *
    *                                                              *
    ***************************************************************/
    
    (defun abTreeExample (objects)
      (abCreateTreeExample objects)
      (hiDisplayForm abTreeExampleForm)
      )
    

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

    This example is a different approach, intended for selection of objects with a name attribute (e.g. instances):

    /* abSelectObjByName.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Mar 26, 2003 
    Modified   Nov 16, 2008 
    By         A.D.Beckett
    
    Little utility for selecting instances, terminals or nets by name
    (at least, the shapes associated with them). To use:
    
    abSelectObjByName('instances)
    abSelectObjByName('nets)
    abSelectObjByName('netsAndVias)
    abSelectObjByName('terminals)
    abSelectObjByName('figGroups) ; OA only
    
    netsAndVias is for CDB releases - with OA, vias are on the net
    anyway.
    
    Extended to allow a function to be passed to do the "selection". so
    forms can be used for other things (e.g. abProtect package)
    
    ***************************************************
    
    SCCS Info: @(#) abSelectObjByName.il 11/16/08.19:26:07 1.4
    
    */
    
    /***************************************************************
    *                                                              *
    *                (abCreateSelectObjByNameForm)                 *
    *                                                              *
    *                       Create the form                        *
    *                                                              *
    ***************************************************************/
    
    (procedure (abCreateSelectObjByNameForm)
      (let (objects)
           (setq objects (hiCreateListBoxField
                          ?name 'objects
                          ?choices nil
                          ?value nil
                          ?multipleSelect t
                          ?doubleClickCB "(abSelectObjByNameCB (hiGetCurrentForm))"
                          ?valueByPosition t
                          ))
           (hiCreateAppForm
            ?name 'abSelectObjByNameForm
            ?fields (list
                     (list objects 0:0 300:400)
                     )
            ?attachmentList (list
                             hicLeftPositionSet|hicTopPositionSet|
                             hicRightPositionSet|hicBottomPositionSet
                             )
            ?initialSize 300:400
            ?formTitle "Select things"
            ?callback 'abSelectObjByNameCB
            )
           ))
    
    /***************************************************************
    *                                                              *
    *    (abSelectObjByNameList cellView type names selectFunc)    *
    *                                                              *
    *          Given a list of names of a particular type          *
    *          (nets, instances, terminals), select them           *
    *      either directly, or using the selectFunc function       *
    *                                                              *
    ***************************************************************/
    
    (procedure (abSelectObjByNameList cellView type names selectFunc)
      (let (objects object)
           ;-----------------------------------------------------------------
           ; Determine the objects which will be selected
           ;-----------------------------------------------------------------
           (setq objects 
                 (foreach mapcan name names
                          (case type
                                ;--------------------------------------------
                                ; For instances, look for either instance or mosaic
                                ;--------------------------------------------
                                (instances
                                 (list
                                  (or
                                   (dbFindAnyInstByName cellView name)
                                   (dbFindMosaicByName cellView name)
                                   )
                                  ))
                                ;--------------------------------------------
                                ; For nets, include the pin figures, and the
                                ; net figures
                                ;--------------------------------------------
                                (nets
                                 (setq object (dbFindNetByName cellView name))
                                 (nconc 
                                  (dbGetq (dbGetq object pins) fig)
                                  (dbGetq object figs)
                                  ))
                                ;--------------------------------------------
                                ; For netsAndVias, include the pin figures, and the
                                ; net figures, and any vias on the nets
                                ;--------------------------------------------
                                (netsAndVias
                                 (setq object (dbFindNetByName cellView name))
                                 (nconc 
                                  (dbGetq (dbGetq object pins) fig)
                                  (dbGetq object figs)
                                  (setof inst (dbGetq 
                                               (dbGetq object instTerms) inst)
                                         (leIsContact inst))
                                  ))
                                ;--------------------------------------------
                                ; For terminals, find the pin figures
                                ;--------------------------------------------
                                (terminals
                                 (dbGetq
                                  (dbGetq
                                   (dbFindTermByName cellView name)
                                   pins)
                                  fig
                                  ))
                                ;--------------------------------------------
                                ; For figGroups, just return them directly
                                ;--------------------------------------------
                                (figGroups
                                  (list
                                    (dbGetFigGroupByName cellView name)
                                    )
                                  )
                                ))
                 )
           ;-----------------------------------------------------------------
           ; Now select them (deselecting first)
           ;-----------------------------------------------------------------
           (if selectFunc 
             (foreach obj objects
                      (funcall selectFunc obj)
                      )
             ; else
             (progn
               (geDeselectAllFig cellView)
               (foreach obj objects
                        (geSelectFig obj)
                        )
               )
             )
           t
           )
      )
    
    /***************************************************************
    *                                                              *
    *                  (abSelectObjByNameCB form)                  *
    *                                                              *
    *   the form callback - does the selection, and zooms to fit   *
    *                     the selected objects                     *
    *                                                              *
    ***************************************************************/
    
    (procedure (abSelectObjByNameCB form)
      (abSelectObjByNameList 
       (getq form cellView)
       (getq form type) 
       (hiGetListBoxValue (getq form objects))
       (getq form selectFunc)
       )
      (unless (getq form selectFunc)
        (leZoomToSelSet)
        )
      t
      )
    
    /****************************************************************
    *                                                               *
    *       (abSelectObjByName [type [cellView [selectFunc]]])      *
    *                                                               *
    * Passed a type - instances, nets or terminals, and a cellView, *
    *  give the user a list of objects to select. Also can give a   *
    * a function object to do the "selection" if you want it to do  *
    *                 something other than selection                *
    *                                                               *
    ****************************************************************/
    
    (procedure (abSelectObjByName @optional (type 'instances) 
                                  (cellView (geGetEditCellView))
                                  selectFunc)
      (let (objects intType)
           (unless (boundp 'abSelectObjByNameForm)
                   (abCreateSelectObjByNameForm))
           (when cellView
                 (setq intType (if (eq type 'netsAndVias) 'nets type))
                 (setq objects (dbGet cellView intType))
                 (hiSetFormName abSelectObjByNameForm
                                (sprintf nil "Select %s by name" type))
                 ;-----------------------------------------------------------
                 ; Record what kind of objects these are
                 ;-----------------------------------------------------------
                 (putpropq abSelectObjByNameForm type type)
                 (putpropq abSelectObjByNameForm cellView cellView)
                 (putpropq abSelectObjByNameForm selectFunc selectFunc)
                 ;-----------------------------------------------------------
                 ; Deselect everything first
                 ;-----------------------------------------------------------
                 (putpropq (getq abSelectObjByNameForm objects) nil value)
                 ;-----------------------------------------------------------
                 ; Handle mosaics - return mosaic name instead
                 ;-----------------------------------------------------------
                 (when (eq type 'instances)
                       (setq objects 
                             (foreach mapcar object objects
                                      (or (dbGetq object mosaic) object))))
                 ;-----------------------------------------------------------
                 ; Now update the choices
                 ;-----------------------------------------------------------
                 (putpropq (getq abSelectObjByNameForm objects)
                           (sort (dbGetq objects name) 
                                 (lambda (a b) (minusp (alphaNumCmp a b)))
                                 )
                           choices)
                 ;-----------------------------------------------------------
                 ; And display it
                 ;-----------------------------------------------------------
                 (hiDisplayForm abSelectObjByNameForm)
                 )
           t
           )
      )
    

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 9 years ago
    Neither of these may be exactly what you want - but at least it gives you some code to borrow from.
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Sharif H N
    Sharif H N over 9 years ago
    Yes, above codes are helping me to move forward. Thanks 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