Home
  • Products
  • Solutions
  • Support
  • Company

This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  • Products
  • Solutions
  • Support
  • Company
Community PCB Design & IC Packaging (Allegro X) Allegro X Scripting - TCL Getting Diode Name

Stats

  • State Verified Answer
  • Replies 5
  • Subscribers 11
  • Views 737
  • Members are here 0
More Content

Getting Diode Name

karthikeyank
karthikeyank 3 months ago

HI,

I was trying get the part name starts with the letter k and diode name. i can be able to retrieve the part name. i dont know how to access the diode. can anyone plz help me out.

Expected Output -

Part Name: K00_012

Diode Name: D00_012

Program:

for {set j 0} {$j < $objlength} {incr j} {
set lPage [lindex $selectedobjs $j]
set lPageNameCS [DboTclHelper_sMakeCString]
$lPage GetName $lPageNameCS
set lPageName [DboTclHelper_sGetConstCharPtr $lPageNameCS]
#puts $lPageName
set PlIter [$lPage NewPartInstsIter $lStatus]
set lPart [$PlIter NextPartInst $lStatus]
while {$lPart != $lNullObj } {
set lReferenceName [DboTclHelper_sMakeCString]
$lPart GetReference $lReferenceName
set lReferenceNameS [DboTclHelper_sGetConstCharPtr $lReferenceName]
#puts $lReferenceNameS
set firstLetter [string range $lReferenceNameS 0 0]
if {$firstLetter == "K" } {
set lOccCount [$lPart GetOccurrencesCount]
for {set i 0} {$i < $lOccCount} {incr i} {
set lOcc [$lPart GetOccurrencesAtPos $i]
set lReferenceName1 [DboTclHelper_sMakeCString]
$lOcc GetPathName $lReferenceName1
set lReferenceNameS1 [DboTclHelper_sGetConstCharPtr $lReferenceName1]
puts $lReferenceNameS1
set inpPrse [lindex [split $lReferenceNameS1 "/"] 1]
set lIter [$lPart NewPinsIter $lStatus]
set lPin [$lIter NextPin $lStatus]
while {$lPin != $lNullObj } {
set lPinName [DboTclHelper_sMakeCString]
$lPin GetPinName $lPinName
set lPinName [DboTclHelper_sGetConstCharPtr $lPinName]
if {[string first "+" $lPinName] >= 0} {

puts $inpPrse
#---How to find diode name

}
set lPin [$lIter NextPin $lStatus]
}
delete_DboPartInstPinsIter $lIter
}
}
set lPart [$PlIter NextPartInst $lStatus]
}
delete_DboPagePartInstsIter $PlIter

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

    karthikeyank 

    You can use regexp to check the word start with K or D.

    for example, if {[regexp {^(K|D)} $lReferenceNameS] == 1} {do your processing.}

    Try and let me know your feedback.

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

    Actually, my requirement is I want to compare K Part and Connected Diode part is same name just k and d difference. 

    For Ex: My K part is: K00_012 means Diode Name Should be: D00_012

    By using this: if {[regexp {^(K|D)} $lReferenceNameS] == 1}

    It will return every name. But I'm not able to find where Diode was connected.

    Error Case: For ex: K00_012->D00_013 and K00_013->D00_012

    I want to find these kinda cases. so, I want to get the Diode name by connections.

    Thanks,

    Karthikeyan

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

    karthikeyank  I am sharing a sample code below; it will dump the connectivity of pin with diode like below.

    Where K is starting letter of refdes of a part and D is for Doide.

    K00_13-->D00_13
    K00_012-->D00_012
    K00_14-->D00_14
    K00_15-->D00_15

    set lSession $::DboSession_s_pDboSession
    DboSession -this $lSession
    set lNullObj NULL
    set lStatus [DboState]
    set lDesign [$lSession GetActiveDesign]
    set lSchi_Name [DboTclHelper_sMakeCString]
    set lPartCount 0
    set lReferenceName [DboTclHelper_sMakeCString ]
    set lPropName1 [DboTclHelper_sMakeCString ]
    set lPropValue [DboTclHelper_sMakeCString]
    set lSchematicIter [$lDesign NewViewsIter $lStatus $::IterDefs_SCHEMATICS]
    #get the first schematic view
    set lView [$lSchematicIter NextView $lStatus]
    # set lPage_Name [DboTclHelper_sMakeCString]
    while { $lView != $lNullObj} {
    #dynamic cast from DboView to DboSchematic
    set lSchematic [DboViewToDboSchematic $lView]
    $lSchematic GetName $lSchi_Name
    set lPagesIter [$lSchematic NewPagesIter $lStatus]
    #get the first page
    set lPage [$lPagesIter NextPage $lStatus]
    # puts [DboTclHelper_sGetConstCharPtr $lSchi_Name]
    while {$lPage!=$lNullObj} {
    # puts [DboTclHelper_sGetConstCharPtr $lPage_Name]
    set lPartInstsIter [$lPage NewPartInstsIter $lStatus]
    #get the first part inst
    set lInst [$lPartInstsIter NextPartInst $lStatus]
    while {$lInst!=$lNullObj} {
    #dynamic cast from DboPartInst to DboPlacedInst
    set lPlacedInst [DboPartInstToDboPlacedInst $lInst]
    if {$lPlacedInst != $lNullObj} {
    set lObjType [$lPlacedInst GetObjectType]
    if {$lObjType == 13} {
    #placeholder: do your processing on $lPlacedInst
    $lPlacedInst GetReference $lReferenceName
    set lRefName [DboTclHelper_sGetConstCharPtr $lReferenceName]
    if {[regexp {^D} $lRefName]== 1} {
    # puts $lRefName
    set lPinIter [$lPlacedInst NewPinsIter $lStatus]
    set lPin [$lPinIter NextPin $lStatus]
    while {$lPin != $lNullObj} {

    # puts $lPin
    set lWire [$lPin GetWire $lStatus]
    if {$lWire != $lNullObj} {

    set lConnpinIter [$lWire NewPortInstsIter $lStatus $::IterDefs_PORTS]
    set lConnPin [$lConnpinIter NextPortInst $lStatus]
    while {$lConnPin != $lNullObj} {

    # puts $lConnPin
    set lPrentObject [$lConnPin GetOwner]
    $lPrentObject GetReference $lPropName1
    set lPrentRfdes [DboTclHelper_sGetConstCharPtr $lPropName1]
    if {[regexp {^K} $lPrentRfdes] == 1 } {

    puts "$lPrentRfdes-->$lRefName"
    }
    set lConnPin [$lConnpinIter NextPortInst $lStatus]
    }

    }
    set lPin [$lPinIter NextPin $lStatus]
    }
    # puts $lRefName

    }
    }
    }
    #get the next part inst
    set lInst [$lPartInstsIter NextPartInst $lStatus]
    }
    delete_DboPagePartInstsIter $lPartInstsIter
    #get the next page
    set lPage [$lPagesIter NextPage $lStatus]
    }
    delete_DboSchematicPagesIter $lPagesIter
    #get the next schematic view
    set lView [$lSchematicIter NextView $lStatus]
    }
    delete_DboLibViewsIter $lSchematicIter

    Try and let me know your comments

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

    Thanks for the support.

    While using above code: GetOwner Name returns the Diode Name. Like lRefName -->D00_14 lPrentRfdes--> D00_14

    lConnPin this loop didn't return the K Partname.

    So, I've Updated the code now it's working fine.

    Program:

    set selectedobjs [GetSelectedPMItems]
    set objlength [llength $selectedobjs]
    set lStatus [DboState]
    set lNullObj NULL
    set lSchi_Name [DboTclHelper_sMakeCString]
    set lPartCount 0
    set lReferenceName [DboTclHelper_sMakeCString ]
    set lPropName1 [DboTclHelper_sMakeCString ]
    set lPropValue [DboTclHelper_sMakeCString]
    for {set j 0} {$j < $objlength} {incr j} {
    set lPage [lindex $selectedobjs $j]
    set lPageNameCS [DboTclHelper_sMakeCString]
    $lPage GetName $lPageNameCS
    set lPageName [DboTclHelper_sGetConstCharPtr $lPageNameCS]
    set lPartInstsIter [$lPage NewPartInstsIter $lStatus]
    set lInst [$lPartInstsIter NextPartInst $lStatus]
    while {$lInst!=$lNullObj} {
    set lPlacedInst [DboPartInstToDboPlacedInst $lInst]
    if {$lPlacedInst != $lNullObj} {
    set lObjType [$lPlacedInst GetObjectType]
    if {$lObjType == 13} {
    $lPlacedInst GetReference $lReferenceName
    set lRefName [DboTclHelper_sGetConstCharPtr $lReferenceName]
    if {[regexp {^D} $lRefName]== 1} {
    #puts $lRefName
    set lPinIter [$lPlacedInst NewPinsIter $lStatus]
    set lPin [$lPinIter NextPin $lStatus]
    while {$lPin != $lNullObj} {
    set lWire [$lPin GetWire $lStatus]
    if {$lWire != $lNullObj} {
    set lWireIter1 [$lWire NewConnectedWiresIter $lStatus]
    set lWire2 [$lWireIter1 NextWire $lStatus]
    while {$lWire2!=$lNullObj} {
    set lConnpinIter [$lWire2 NewPortInstsIter $lStatus $::IterDefs_PORTS]
    set lConnPin [$lConnpinIter NextPortInst $lStatus]
    while {$lConnPin != $lNullObj} {
    #puts $lConnPin
    set lPrentObject [$lConnPin GetOwner]
    $lPrentObject GetReference $lPropName1
    set lPrentRfdes [DboTclHelper_sGetConstCharPtr $lPropName1]
    #puts $lPrentRfdes
    if {[regexp {^K} $lPrentRfdes] == 1 } {
    puts "$lPrentRfdes-->$lRefName"
    }
    set lConnPin [$lConnpinIter NextPortInst $lStatus]
    }
    set lWire2 [$lWireIter1 NextWire $lStatus]
    }
    }
    set lPin [$lPinIter NextPin $lStatus]
    }

    }
    }
    }
    set lInst [$lPartInstsIter NextPartInst $lStatus]
    }
    delete_DboPagePartInstsIter $lPartInstsIter
    }

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

    karthikeyank 

    Good to know it helped.

    Thanks!

    • 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