• 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. How to properly move a part between OLBs with TCL?

Stats

  • State Verified Answer
  • Replies 11
  • Subscribers 15
  • Views 1788
  • Members are here 0
More Content

How to properly move a part between OLBs with TCL?

andakConsultingLtd
andakConsultingLtd 3 months ago

I am trying to clean up some old libraries i.e. move unused parts from active.olb to unused.olb. The code is presented below. Everything works pretty well except that there is something hanging inside active.olb that prevents creating a part that was there before. E.g. if PART_123 was moved from active olb to unused.olb, I can not create PART_123 again. If I look inside active.olb file, PART_123 is still mentioned, despite not being shown in the lib tree structure. I guess I am missing some cleanup in my code, but I can't figure what exactly, so I am asking for your help.

set lSession [DboTclHelper_sCreateSession]
set lStatus [DboState]
set lNullObj NULL

#Provide the location of olb FROM which package should be copied.
set lSourceLibPath [file normalize {D:\ACTIVE.OLB}]
set lSourceLibPathCstring [DboTclHelper_sMakeCString $lSourceLibPath]
set lSourceLib [$lSession GetLib $lSourceLibPathCstring $lStatus]

#Provide the location of olb TO which package should be copied.
set lDestnLibPath [file normalize {D:\UNUSED.OLB}]
set lDsctnLibPathCstring [DboTclHelper_sMakeCString $lDestnLibPath]
set lDestnLib [$lSession GetLib $lDsctnLibPathCstring $lStatus]

#parse all packages in the olb
set pkgIter [$lSourceLib NewPackagesIter $lStatus]
set pPkg [$pkgIter NextPackage $lStatus]

while {$pPkg!=$lNullObj} {
    set pActualPkgName [DboTclHelper_sMakeCString]
    $pPkg GetName $pActualPkgName
    $lDestnLib CopyPackageAll $pPkg $pActualPkgName $lStatus
    $lSourceLib DeletePackage $pPkg

    puts [DboTclHelper_sGetConstCharPtr $pActualPkgName]
    set pPkg [$pkgIter NextPackage $lStatus]
}

$lDestnLib MarkModified
$lSourceLib MarkModified

$lSession MarkAllLibForSave $lDestnLib
$lSession SaveLib $lDestnLib
$lSession RemoveLib $lDestnLib

$lSession MarkAllLibForSave $lSourceLib
$lSession SaveLib $lSourceLib
$lSession RemoveLib $lSourceLib

DboTclHelper_sDeleteSession $lSession

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

    This is helpful CadAP

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

    Hi there,

    1. Copy an existing OLB file to the test location, one that has a few parts in it
    2. Open this OLB in Capture
    3. Delete all existing parts in the library, to start from scratch
    4. Create 2 new parts: PART_ABC and PART_123
    5. Close parts and save library
    6. Load/run the tcl script with source {scriptName.tcl} (result below)
    7. Save OLB and then Right click the libary to create again PART_ABC (see image below)
    8. I get the error as shown

    Step 4:

    Step 5, before running script:

    result after step 6:

    step 7:

    Step 8:

    After step 6, if you open the OLB with a text editor, you can still see PART_ABC and PART_123 mentioned in the file, despite them being deleted, and I think this is what causes the error.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • andakConsultingLtd
    0 andakConsultingLtd 2 months ago in reply to andakConsultingLtd

    Hi CadAP , did you have the chance to replicate the issue?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • CadAP
    0 CadAP 2 months ago in reply to andakConsultingLtd

    andakConsultingLtd 

    Please below api instead of DeletePackage:

    RemovePackage(pPackage) : returns DboState
    Class : DboLib(DboBaseObject):
    Parameters:
    pPackage: DboPackage *

    $lDboLibrary DeletePackage $pPackage

    $lDboLibrary RemovePackage $pPackage

    Once done save and close the library and reopen it again

    Hope it helps.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • PatEscher
    +1 PatEscher 1 month ago in reply to andakConsultingLtd

    use DeletePackageAll

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Reject 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