• 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. TCl script to replace selected parts with a component from...

Stats

  • State Verified Answer
  • Replies 16
  • Subscribers 14
  • Views 5247
  • Members are here 0
More Content

TCl script to replace selected parts with a component from library

soliman1991
soliman1991 over 1 year ago

Hello, 

I need to replace components in a schematic page with parts from the library, I tried DboPage_ReplaceInst, but the documentation is very vague.

Here is my attempt for reference: 

set selected [GetSelectedObjects]
puts $selected
set newPackageStr {CAP CER 0.1UF 10V X8M 0201} #that is the package name in the library
set lStatus [DboState]
set lSession $::DboSession_s_pDboSession
DboSession -this $lSession


set pLibName [file normalize {d:\random\Library.olb}]
set lLibName [DboTclHelper_sMakeCString $pLibName]
set lLib [$lSession GetLib $lLibName $lStatus]

set LibraryName [DboTclHelper_sMakeCString]

$lLib GetName $LibraryName
set newPackageName [DboTclHelper_sMakeCString newPackageStr]
set newPackage [$lLib GetPackage $newPackageName $lStatus]

foreach obj $selected {
    set device [$obj GetDevice $lStatus]
    DboPage_ReplaceInst $obj $newPackageName $newPackage $device $lStatus 0 0 1 1
}
  • Sign in to reply
  • Cancel
  • CadAP
    0 CadAP over 1 year ago

    Hello Soliman1991,

    Please use the below code to replace the selected part with a part from another library.

    set selected [GetSelectedObjects]
    # puts $selected
    set lPackage "C" ;#make sure the package name in the library.
    set lStatus [DboState]
    set lSession $::DboSession_s_pDboSession
    DboSession -this $lSession


    set pLibName [file normalize {d:\random\Library.olb}]

    foreach obj $selected {
    # set device [$obj GetDevice $lStatus]
    # $lPage ReplaceInst $obj $newPackageStr $lPart $device $lStatus 0 0 1 1
    ReplacePart "$pLibName" "$lPackage" "$lPackage.NORMAL" ""

    }

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

    what would be the difference between ReplaceInst and ReplacePart then?
    Are we really replacing the instances by this command or are we replacing the complete Parts, so that it automatically replaces all instances using this part?

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

    Unfortunately ReplacePart doesn't preserve RefDes, anyway around that?

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

    Hello Soliman1991,

    Please use the below code to replace the selected part with a part from another library with preserver refdef.

    set selected [GetSelectedObjects]
    # puts $selected
    set newPackageStr [DboTclHelper_sMakeCString "C"] ;#that is the package name in the library
    set lStatus [DboState]
    set lSession $::DboSession_s_pDboSession
    DboSession -this $lSession


    set pLibName [file normalize {d:\random\Library.olb}]

    foreach obj $selected {
    set device [$obj GetDevice $lStatus]
    set lPart [$obj GetPart $lStatus]
    set lPage [$obj GetOwner]
    $lPage ReplaceInst $obj $newPackageStr $lPart $device $lStatus 1 0 1 1
    # ReplacePart "$pLibName" "$lPackage" "$lPackage.NORMAL" ""

    }

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

    Hi PatEscher,

    Yes, ReplacePart is completing replacing the Part with the new one taken from library. While in ReplaceInst we can preserve previous value.

    • Cancel
    • Vote Up +1 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