• 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 part occurrences reference designators and pin numbers...

Stats

  • State Verified Answer
  • Replies 6
  • Answers 1
  • Subscribers 13
  • Views 1459
  • Members are here 0
More Content

Get part occurrences reference designators and pin numbers connected to a flat net

VB202505089850
VB202505089850 3 months ago

Hello,

I want to iterate through all the flat nets in my hierarchical design in OrCAD Capture using a Tcl/Tk script. For each net, I need to print the flat net name, the reference designators of the components it is connected to, and the relevant pin numbers of these components (for example: N4958340: U1.2 R11.1 U3.1, N9487723: U1.1 U1.3).

However, I am having trouble retrieving the reference designators of the part occurrences. I can only access the reference designators of the part instances, but that is not what I need. Below is my code so far—perhaps someone can help me:

variable cstr DboTclHelper_sMakeCString
variable str DboTclHelper_sGetConstCharPtr

set dsn [GetActivePMDesign]

set lStatus [DboState]

set lNullObj NULL

# Get iterator for flat nets
set netIter [$dsn NewFlatNetsIter $lStatus]
if {$netIter == $lNullObj} {
  return
}

# Iterate over flat nets
set net [$netIter NextFlatNet $lStatus]
while {$net != $lNullObj} {

  # Get net name
  set netNameCStr [$cstr]
  if {[catch {$net GetName $netNameCStr}]} {
    set netName ""
  } else {
    set netName [$str $netNameCStr]
  }

  if {$netName != ""} {
    # Get port (pins) connected to this net
    set pinIter [$net NewPortOccurrencesIter $lStatus]
    set pinList {}

    set pin [$pinIter NextPortOccurrence $lStatus]

    while {$pin != $lNullObj} {
      set pinInst [$pin GetPortInst $lStatus]

      # Get reference designator into $refdes
      # How to get it? I need to find the part occurrence somehow, either from the port occurrence or from the flat net, but how?

      # Get pin number
      set pinNumCStr [$cstr]
      if {[catch {$pinInst GetPinNumber $pinNumCStr}]} {
        set pinNum ""
      } else {
        set pinNum [$str $pinNumCStr]
      }

      if {$refdes != "" && $pinNum != ""} {
        lappend pinList "$refdes.$pinNum"
      }
      set pin [$pinIter NextPortOccurrence $lStatus]
    }
    delete_DboFlatNetPortOccurrencesIter $pinIter

    # Store the net and its pins (sorted for consistency)
    if {[llength $pinList] > 0} {
    dict set netsdict $netName [lsort $pinList]
    }
  }
  set net [$netIter NextFlatNet $lStatus]

}

delete_DboDesignFlatNetsIter $netIter

  • Sign in to reply
  • Cancel
Parents
  • CadAP
    0 CadAP 3 months ago

    @VB202505089850

    Please find the the code below i have added below section in your code to get placed part and then refdes.:

    ++++++++++++++++++++++++

    set lPropRefdesStr [DboTclHelper_sMakeCString "Part Reference"]
    set lPropValStr [DboTclHelper_sMakeCString]

    set lPlacedINst [$pinInst GetOwner]
    set lState [$lPlacedINst GetEffectivePropStringValue $lPropRefdesStr $lPropValStr]
    set refdes [DboTclHelper_sGetConstCharPtr $lPropValStr]

    +++++++++++++++++++++++++++++++++

     

    variable cstr DboTclHelper_sMakeCString
    variable str DboTclHelper_sGetConstCharPtr
    set lPropRefdesStr [DboTclHelper_sMakeCString "Part Reference"]
    set lPropValStr [DboTclHelper_sMakeCString]
    set dsn [GetActivePMDesign]

    set lStatus [DboState]

    set lNullObj NULL

    # Get iterator for flat nets
    set netIter [$dsn NewFlatNetsIter $lStatus]
    if {$netIter == $lNullObj} {
    return
    }

    # Iterate over flat nets
    set net [$netIter NextFlatNet $lStatus]
    while {$net != $lNullObj} {

    # Get net name
    set netNameCStr [$cstr]
    if {[catch {$net GetName $netNameCStr}]} {
    set netName ""
    } else {
    set netName [$str $netNameCStr]
    }

    if {$netName != ""} {
    # Get port (pins) connected to this net
    set pinIter [$net NewPortOccurrencesIter $lStatus]
    set pinList {}

    set pin [$pinIter NextPortOccurrence $lStatus]

    while {$pin != $lNullObj} {
    set pinInst [$pin GetPortInst $lStatus]



    # Get reference designator into $refdes
    # How to get it? I need to find the part occurrence somehow, either from the port occurrence or from the flat net, but how?
    set lPlacedINst [$pinInst GetOwner]
    set lState [$lPlacedINst GetEffectivePropStringValue $lPropRefdesStr $lPropValStr]
    set refdes [DboTclHelper_sGetConstCharPtr $lPropValStr]
    # Get pin number
    set pinNumCStr [$cstr]
    if {[catch {$pinInst GetPinNumber $pinNumCStr}]} {
    set pinNum ""
    } else {
    set pinNum [$str $pinNumCStr]
    }

    if {$refdes != "" && $pinNum != ""} {
    lappend pinList "$refdes.$pinNum"
    }
    set pin [$pinIter NextPortOccurrence $lStatus]
    }
    delete_DboFlatNetPortOccurrencesIter $pinIter

    # Store the net and its pins (sorted for consistency)
    if {[llength $pinList] > 0} {
    dict set netsdict $netName [lsort $pinList]
    }
    }
    set net [$netIter NextFlatNet $lStatus]

    }

    delete_DboDesignFlatNetsIter $netIter

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • VB202505089850
    0 VB202505089850 3 months ago in reply to CadAP

    Thanks CadAP , but i think it will only give me the Ref Des of the part instances, isn't it? I need the Ref Des of the part occurrences.

    Since you use:
    set lState [$lPlacedINst GetEffectivePropStringValue $lPropRefdesStr $lPropValStr]

    Where lPlacedINst is the part instance.

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • VB202505089850
    0 VB202505089850 3 months ago in reply to CadAP

    Thanks CadAP , but i think it will only give me the Ref Des of the part instances, isn't it? I need the Ref Des of the part occurrences.

    Since you use:
    set lState [$lPlacedINst GetEffectivePropStringValue $lPropRefdesStr $lPropValStr]

    Where lPlacedINst is the part instance.

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • CadAP
    +1 CadAP 3 months ago in reply to VB202505089850

    VB202505089850 

    Please updated code which helps to get part occurrences refdes.

    I have added below proc to get part occurences in your code.

    ++++++++++++++++++++++++++++++++++++++++

    proc DumpPartOccurrences {lObj} {
    # set lObj [GetSelectedObjects]
    set lStatus [DboState]
    set lPatOcc {}
    foreach obj $lObj {

    set lOccCount [$obj GetOccurrencesCount]
    for {set i 0} {$i<$lOccCount} {incr i} {
    set lOcc [$obj GetOccurrencesAtPos $i]

    lappend lPatOcc $lOcc
    }
    }
    return $lPatOcc
    }

    +++++++++++++++++++++++++++++++++++++++

    proc DumpPartOccurrences {lObj} {
    # set lObj [GetSelectedObjects]
    set lStatus [DboState]
    set lPatOcc {}
    foreach obj $lObj {

    set lOccCount [$obj GetOccurrencesCount]
    for {set i 0} {$i<$lOccCount} {incr i} {
    set lOcc [$obj GetOccurrencesAtPos $i]

    lappend lPatOcc $lOcc
    }
    }
    return $lPatOcc
    }


    variable cstr DboTclHelper_sMakeCString
    variable str DboTclHelper_sGetConstCharPtr
    set lPropRefdesStr [DboTclHelper_sMakeCString "Part Reference"]
    set lPropValStr [DboTclHelper_sMakeCString]
    set dsn [GetActivePMDesign]

    set lStatus [DboState]

    set lNullObj NULL

    # Get iterator for flat nets
    set netIter [$dsn NewFlatNetsIter $lStatus]
    if {$netIter == $lNullObj} {
    return
    }

    # Iterate over flat nets
    set net [$netIter NextFlatNet $lStatus]
    while {$net != $lNullObj} {

    # Get net name
    set netNameCStr [$cstr]
    if {[catch {$net GetName $netNameCStr}]} {
    set netName ""
    } else {
    set netName [$str $netNameCStr]
    }

    if {$netName != ""} {
    # Get port (pins) connected to this net
    set pinIter [$net NewPortOccurrencesIter $lStatus]
    set pinList {}

    set pin [$pinIter NextPortOccurrence $lStatus]

    while {$pin != $lNullObj} {
    set pinInst [$pin GetPortInst $lStatus]



    # Get reference designator into $refdes
    # How to get it? I need to find the part occurrence somehow, either from the port occurrence or from the flat net, but how?
    set lPlacedINst [$pinInst GetOwner]
    set lPlacedOcc [DumpPartOccurrences $lPlacedINst]
    foreach lOcc $lPlacedOcc {
    set lState [$lOcc GetEffectivePropStringValue $lPropRefdesStr $lPropValStr]
    set refdes [DboTclHelper_sGetConstCharPtr $lPropValStr]
    }
    # Get pin number
    set pinNumCStr [$cstr]
    if {[catch {$pinInst GetPinNumber $pinNumCStr}]} {
    set pinNum ""
    } else {
    set pinNum [$str $pinNumCStr]
    }

    if {$refdes != "" && $pinNum != ""} {
    lappend pinList "$refdes.$pinNum"
    }
    set pin [$pinIter NextPortOccurrence $lStatus]
    }
    delete_DboFlatNetPortOccurrencesIter $pinIter

    # Store the net and its pins (sorted for consistency)
    if {[llength $pinList] > 0} {
    dict set netsdict $netName [lsort $pinList]
    }
    }
    set net [$netIter NextFlatNet $lStatus]

    }

    delete_DboDesignFlatNetsIter $netIter

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
  • VB202505089850
    0 VB202505089850 3 months ago in reply to CadAP

    Thank you CadAP  ! It seems to be working.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
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