• 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. Retriving Info from Tree Items

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 143
  • Views 8745
  • 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

Retriving Info from Tree Items

kdolan
kdolan over 3 years ago

Hi, I am trying to familiarize myself with how to make tree's via Cadence Skill and then how to insert them into a GUI. Where I am getting stuck is retrieving information from the selected tree items.

I've added some simple code below as an example. My intentions are for when the user clicks the button ('getTreeItemInfo), this function will return the values from the headers of the selected items. For example, the users selects item0 in the tree, this should return (1 101 201), the three values from headers for item 1. This would ideally also work for multiple selections. 

Any help is greatly appreciated.

Keelan

procedure( TreeGUI()
prog( (TreeGUIForm treeGuiField getTreeItemInfo)


treeGuiField = hiCreateTreeTable(
?name 'treeGuiField
?headers list(list("Counter" 125 'left)
list("Counter +100" 125 'left)
list("Counter +200" 125 'left)
)
?choice getMyTree()
)

getTreeItemInfo = hiCreateFormButton(
?name 'getTreeItemInfo
?buttonText "Get Item Info"
?callback "hiTreeTableGetSelectedItems(TreeGUIForm~>treeGuiField)"
)


TreeGUIForm = hiCreateAppForm(
?name 'TreeGUIForm
?formTitle "Tree Test"
?fields list(
list(treeGuiField 10:15 410:350 10)
list(getTreeItemInfo 10:370 100:30 10)
)
?dialogStyle 'modeless
?buttonLayout '(OKCancelApply)
?initialSize t
)
hiDisplayForm(TreeGUIForm)
);let
);procedure

procedure(getMyTree()
prog( (outputTree outputTreeItem)

outputTree = hiCreateTree('outputTree)
for(i 1 10
outputTreeItem = hiCreateTreeItem('outputTreeItem list(sprintf(nil "%L" i) sprintf(nil "%L" i+100) sprintf(nil "%L" i+200)))
hiTreeAppendItem(outputTree outputTreeItem)
)

return(outputTree)
);prog
);procedure

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago

    The main issue you had was that each tree item needs to be a unique symbol (you were using the same for all items). I've adapted your code slightly and added a callback function to print out the selected information:

    procedure( TreeGUI()
      prog( (TreeGUIForm treeGuiField getTreeItemInfo)
    
        treeGuiField = hiCreateTreeTable(
          ?name 'treeGuiField
          ?headers list(list("Counter" 125 'left)
            list("Counter +100" 125 'left)
            list("Counter +200" 125 'left)
            )
          ?choice getMyTree()
        )
    
        getTreeItemInfo = hiCreateFormButton(
          ?name 'getTreeItemInfo
          ?buttonText "Get Item Info"
          ;?callback "hiTreeTableGetSelectedItems(TreeGUIForm~>treeGuiField)"
          ?callback "PrintTreeSelectedItems(TreeGUIForm~>treeGuiField)"
        )
    
        TreeGUIForm = hiCreateAppForm(
          ?name 'TreeGUIForm
          ?formTitle "Tree Test"
          ?fields list(
            list(treeGuiField 10:15 410:350 10)
            list(getTreeItemInfo 10:370 100:30 10)
          )
          ?dialogStyle 'modeless
          ?buttonLayout '(OKCancelApply)
          ?initialSize t 
          )
        hiDisplayForm(TreeGUIForm)
      );let
    );procedure
    
    procedure(getMyTree()
      prog( (outputTree outputTreeItem)
    
        outputTree = hiCreateTree('outputTree)
        for(i 1 10
          ; each tree item needs to be a unique symbol
          outputTreeItem = hiCreateTreeItem(concat('outputTreeItem i) list(sprintf(nil "%L" i) sprintf(nil "%L" i+100) sprintf(nil "%L" i+200)))
          hiTreeAppendItem(outputTree outputTreeItem)
        )
    
        return(outputTree)
      );prog
    );procedure
    
    procedure(PrintTreeSelectedItems(field)
      foreach(item hiTreeTableGetSelectedItems(field)
        printf("Selected: %L : Description: %L\n"
          item hiGetTreeItemDescription(symeval(item))
        )
      )
    )
    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • kdolan
    kdolan over 3 years ago in reply to Andrew Beckett

    That was my issue! Works perfectly now. Thanks Andrew!

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • AurelBuche
    AurelBuche over 3 years ago in reply to kdolan

    Hi, you should also note that hiCreateTree... functions create your objects and associate them in SKILL top level namespace

    This can lead to bugs in case you duplicate your code or reuse the same names somewhere else

    You should wrap your symbols using gensym  to avoid problems in the future

    hiCreateTree(gensym('outputTree))

    hiCreateTreeItem(gensym('outputTreeItem) ...)

    Hope this helps

    Cheers

    Aurélien

    • 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