• 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. Allegro X Scripting - TCL
  3. Get level of hierarchy of part

Stats

  • State Verified Answer
  • Replies 5
  • Subscribers 13
  • Views 2081
  • Members are here 0
More Content

Get level of hierarchy of part

ElecDesinger
ElecDesinger over 1 year ago

I am using Example 3.2.28.2 Iterate over instance occurrence hierarchy as base for my TCL script. How can I check if a part is on main level or inside hierarchy? My design has multi-level hierarchy. 

  • Cancel
  • Sign in to reply
Parents
  • CadAP
    0 CadAP over 1 year ago

    Hi ElecDesigner,

    I think you can try the below suggestion

    1. Iterate over each page .

    2. run below command on the page, if $error is 1 the parts are from block and if error is "Menu command not found" then parts are on top. 

    catch {Menu "View::Ascend Hierarchy"} error1

     puts $error1

    3. if error ==1 then dump the parts else ignore it.

    Please do let me know your feedback.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • ElecDesinger
    0 ElecDesinger over 1 year ago in reply to CadAP

    Hi CadAP, this command did not help. It only tells me if the selected part can be descended or not. I am looking for a command that tells me which level of hierarchy a part is located. 

    Main level: Hierarchy = 0
    Inside one Hierarchal block: Hierarchy = 1
    Inside two Hierarchal blocks: Hierarchy = 2 
    etc. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • CadAP
    +1 CadAP over 1 year ago in reply to ElecDesinger

    Hi ElecDesigner,

    I have created a sample script which will print the part hierarchy level with root schematic as well as schematic under which part is placed.

    Steps to run:

    1. Copy the code in notepad and save with .tcl extension.

    2. Select a part and source the code.

    set lPartNameCs [DboTclHelper_sMakeCString]
    set lSchiNameCs [DboTclHelper_sMakeCString]
    set lPropNameCs [DboTclHelper_sMakeCString "Part Reference"]
    set lPropValueCs [DboTclHelper_sMakeCString]
    set lSelectedObj [GetSelectedObjects]
    set lSession $::DboSession_s_pDboSession
    DboSession -this $lSession
    set lStatus [DboState]
    set lLib [$lSelectedObj GetContainingLib]
    set lPage [$lSelectedObj GetOwner]
    set lSchi [$lPage GetOwner]

    $lSchi GetName $lSchiNameCs

    $lSelectedObj GetEffectivePropStringValue $lPropNameCs $lPropValueCs
    # $ob GetName $lPartNameCs
    set lPropValue [DboTclHelper_sGetConstCharPtr $lPropValueCs]
    set lPartName [DboTclHelper_sGetConstCharPtr $lPartNameCs]

    set lSchiName [DboTclHelper_sGetConstCharPtr $lSchiNameCs]
    set lPrpName [DboTclHelper_sMakeCString "Root View"]
    set lPrpValue [DboTclHelper_sMakeCString]
    $lLib GetEffectivePropStringValue $lPrpName $lPrpValue
    set lcounter 0
    set lRootSchi [DboTclHelper_sGetConstCharPtr $lPrpValue]
    puts [DboTclHelper_sGetConstCharPtr $lPrpValue]

    if {$lRootSchi != $lSchiName} {

    # incr lcounter
    catch {Menu "View::Ascend Hierarchy"} error1
    while {$error1 == 1} {

    catch {Menu "View::Ascend Hierarchy"} error1
    incr lcounter
    }

    }

    puts "Refdes $lPropValue is palced on Schmetic $lSchiName\(Root_SchiName:= $lRootSchi\) at hierachy level $lcounter "

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
  • ElecDesinger
    0 ElecDesinger over 1 year ago in reply to CadAP

    Thanks, this gives the hierarchy level of selected part. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • ElecDesinger
    0 ElecDesinger over 1 year ago in reply to CadAP

    Thanks, this gives the hierarchy level of selected part. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
Cadence Guidelines

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