• 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 use ReplaceCache ?

Stats

  • State Verified Answer
  • Replies 6
  • Subscribers 12
  • Views 2229
  • Members are here 0
More Content

How to use ReplaceCache ?

BT202504251050
BT202504251050 4 months ago

I am working on a Tcl script to automate the process of replacing a .OLB file via File Explorer → Design Cache → Replace Cache.

proc read_ini : Utlize to fetch the .olb path at Capture.ini [ Capture.ini => Part Library Directories => Dir0 ]

proc showCacheEntries:Change Part Library path

My question is why the ReplaceCache has no effect? [ Version : 17.2.0]

ReplaceCache(OldPackageOrSymbolName, OldLibName, NewName, NewLibName, bUpdateCache = 0, bPreserverefDes = 0)


proc showCacheEntries { pDesign } {
set lCacheNameCStr [DboTclHelper_sMakeCString]
set lCacheLibNameCStr [DboTclHelper_sMakeCString]
set lStatus [DboState]
set lCacheObjectsIter [$pDesign NewCachesIter $lStatus $::IterDefs_ALL]
set lCachedObject [$lCacheObjectsIter NextCachedObject $lStatus]

# ==================================
# Get Capture.ini to fetch location
# ==================================
set root [pwd]
set input [GetProductVersion]
if {[regexp {(\d+\.\d+)-\d+} $input match version]} {
puts "Version: $version"
} else {
puts "Version not found."
}
set lLibLocation [read_ini "$root/cdssetup/OrCAD_Capture/${version}.0/capture.ini" "Part Library Directories" "Dir0"]
set lLibLocation [string toupper $lLibLocation]
puts $lLibLocation

while { $lCachedObject!= "NULL" } {
set lCachedLibObject [DboBaseObjectToDboLibObject $lCachedObject]
$lCachedObject GetName $lCacheNameCStr
$pDesign GetSourceLibName $lCacheNameCStr $lCachedLibObject $lCacheLibNameCStr

# ==============================
# Get Design Cache Library Name
# ==============================
set lKey [DboTclHelper_sGetConstCharPtr $lCacheNameCStr]
set lLibrary [DboTclHelper_sGetConstCharPtr $lCacheLibNameCStr]
set lPartNameCStr [DboTclHelper_sMakeCString $lKey]
regexp {[^\\]+$} $lLibrary match
regexp {[^.]+$} $match extension

set NewLibrary "$lLibLocation$match"
set lNewLibNameCStr [DboTclHelper_sMakeCString $NewLibrary]

# ==============================
# Update Library Location
# ==============================

if {$extension == "OLB" && $lLibrary != $NewLibrary} {
puts "### UPDATE ### $lKey : $lLibrary -> $NewLibrary"
# ReplaceCache(OldPackageOrSymbolName, OldLibName, NewName, NewLibName, bUpdateCache = 0, bPreserverefDes = 0)
$pDesign ReplaceCache $lPartNameCStr $lCacheLibNameCStr $lPartNameCStr $lNewLibNameCStr 1 0
}
set lCachedObject [$lCacheObjectsIter NextCachedObject $lStatus]
}
delete_DboDesignCachesIter $lCacheObjectsIter
$lStatus -delete
}

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

    BT202504251050 

    What is the class of "pDesign" you are passing it here?

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

    BT202504251050 

    What is the class of "pDesign" you are passing it here?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • BT202504251050
    0 BT202504251050 4 months ago in reply to CadAP
    proc capShowCacheData { pDesignName } {
        set lStatus [DboState]
        set lSession [DboTclHelper_sCreateSession]
        set lDesignNameCStr [DboTclHelper_sMakeCString $pDesignName]
        set lDesign [$lSession GetDesignAndSchematics $lDesignNameCStr $lStatus]
        if { "NULL" != $lDesign} {
        puts "$pDesignName is open"
        showCacheEntries $lDesign
        $lSession RemoveLib $lDesign
        } else {
        puts "$pDesignName could not open"
        }
        DboTclHelper_sDeleteSession $lSession
        $lStatus -delete
    }

    set lDesignName [DboTclHelper_sMakeCString]
    set lDesign [GetActivePMDesign]
    $lDesign GetName $lDesignName
    set lDesignCacheFile [open $::capGenerateDesignCache::mOutDesignCacheFile w]

    capShowCacheData $lDesignName
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • CadAP
    0 CadAP 4 months ago in reply to BT202504251050

    BT202504251050 

    ReplaceCache works for class DboLib and in your code you are passing DboDesign which is incorrect. Please get the dbolib from cache and pass it as args to ReplaceCache.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • BT202504251050
    0 BT202504251050 4 months ago in reply to CadAP

    Hi CadAP, 

    I’ve been trying to use commands related to returns dbolib as described in OrCAD_Capture_TclTk_Extensions.pdf, but they seem to have no effect.

    Here's a snippet of my code for reference:

    
        if {$extension == "OLB" && $lLibrary != $NewLibrary} {
            puts "### UPDATE ### $lKey : $lLibrary -> $NewLibrary"
    
            # set lLib [$lSession GetOpenLib $lCacheLibNameCStr $lStatus]          <---- ERROR (It seems return DboBaseObject, rather than Dbolib )
            # set lLib [$lSession GetLib $lCacheLibNameCStr $lStatus]              <---- ERROR (It seems return DboBaseObject, rather than Dbolib )
            # set lLib [$lSession GetLibAndSchematics $lCacheLibNameCStr $lStatus] <---- ERROR (It seems return DboBaseObject, rather than Dbolib )
            # set lLib [$pDesign GetContainingLib]                                 <---- NO ERROR (Not work)
    
            $lLib ReplaceCache $lPartNameCStr $lCacheLibNameCStr $lPartNameCStr $lNewLibNameCStr 1 0
    
        }
        set lCachedObject [$lCacheObjectsIter NextCachedObject  $lStatus]
        

    Would you be able to provide a example on how to correctly obtain a DboLib object?

    Thanks for your support!

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

    BT202504251050 

    Please check the below article on the ASK portal:

    Article (20512519) Title: How to update the design cache library path to a new library path
    URL: https://support.cadence.com/apex/ArticleAttachmentPortal?id=a1O3w000009mMUXEA2

    This will help to answer your query.

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

    Cheer!! It seems work well. 

    • 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