• 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 get a symbol from sch and paste it into a specified...

Stats

  • State Verified Answer
  • Replies 4
  • Subscribers 14
  • Views 1794
  • Members are here 0
More Content

How to get a symbol from sch and paste it into a specified OLB library file with tcl script?

Jadystone
Jadystone over 1 year ago

I am collecting symbols from sch to enlarge my olb file. It is not a efficient way that I copy a symbol from design cache and paste it into olb file.

I want to use tcl script to do that.  How to get a symbol from sch and paste it into a specified OLB library file with tcl script?

  • Sign in to reply
  • Cancel
  • CadAP
    0 CadAP over 1 year ago

    Hi Jaydstone,

    Please use the below code to copy the cache lib to a new library.

    Make sure you have provided your library location for copy the packages.

    set lDestnLibPath [file normalize {C:\Users\Desktop\LIBRARY2.OLB}] this line need to modify according to your OLB loaction.


    set lSession $::DboSession_s_pDboSession
    DboSession -this $lSession
    set lStatus [DboState]
    set lNullObj NULL
    set lDesign [$lSession GetActiveDesign]
    set lNameCString [DboTclHelper_sMakeCString ]
    set lSrcLibPathCS [DboTclHelper_sMakeCString]
    set lDesignCacheIter [$lDesign NewCachesIter $lStatus]
    set lCachedObject [$lDesignCacheIter NextCachedObject $lStatus]
    set lPartName [DboTclHelper_sMakeCString]


    #Provide the loaction of OLB in which package should be copied.
    set lDestnLibPath [file normalize {C:\Users\Desktop\LIBRARY2.OLB}]


    set lDsctnLibPathCstring [DboTclHelper_sMakeCString $lDestnLibPath]
    set lDestnLib [$lSession GetLib $lDsctnLibPathCstring $lStatus]
    # set lContLib [$lCachedLibObject GetContainingLib]
    # # set llibname [$lSession GetLib $lContLib $lStatus ]
    while {$lCachedObject != $lNullObj} {
    set lCachedLibObject [DboBaseObjectToDboLibObject $lCachedObject]
    set lContLib [$lCachedLibObject GetContainingLib]
    $lCachedLibObject GetSourceLibName $lSrcLibPathCS
    set lLib [$lSession GetLib $lSrcLibPathCS $lStatus]
    # puts $lLib
    if {$lLib != $lNullObj} {
    set obj1 [$lCachedObject GetName $lNameCString]
    set obj [$lLib GetPackage $lNameCString $lStatus]
    # set obj [$lContLib GetPart $lNameCString $lStatus]
    # set lGetPartName [DboTclHelper_sGetConstCharPtr $lNameCString]
    if {$obj != $lNullObj} {
    # puts $lGetPartName
    # $obj GetName $lPartName
    $lDestnLib CopyPackageAll $obj $lNameCString $lStatus
    # puts [DboTclHelper_sGetConstCharPtr $lPartName]

    }
    }


    set lCachedObject [$lDesignCacheIter NextCachedObject $lStatus]
    }
    # $lDestnLib MarkModified
    $lSession MarkAllLibForSave $lDestnLib
    $lSession SaveLib $lDestnLib
    $lSession RemoveLib $lDestnLib

    delete_DboDesignCachesIter $lDesignCacheIter

    Please let me your feedback how it goes at your end.

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

    I execute  the code. But run to the next step. It gets a NULL obj. SO it fail to continue the script.

    Capture> set obj [$lLib GetPackage $lNameCString $lStatus]
    NULL

    I am sure that the $lNameCstring is NOT null.

    Capture> set lGetName [DboTclHelper_sGetConstCharPtr $lNameCString]
    AG2KSL100C.Normal
    Capture>

    I use regexp to get the prefix name AG2KSL100C (not include .normal) and re-execute the code. It fails to get a NON-NULL obj as well.

    I think the problem is that the source  $lLib  does not exist. So it fails  at "set obj [$lLib GetPackage $lNameCString $lStatus]"

    So we can not use this method.

    I change the $lLib to $lContLib.

    set obj [$lContLib GetPart $lNameCString $lStatus]

    it get a NULL again

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

    HI Jadystone,

    Please use below tcl code:

    set lSession $::DboSession_s_pDboSession
    DboSession -this $lSession
    set lStatus [DboState]
    set lNullObj NULL
    set lDesign [$lSession GetActiveDesign]
    set lNameCString [DboTclHelper_sMakeCString ]
    set lSrcLibPathCS [DboTclHelper_sMakeCString]
    set lDesignCacheIter [$lDesign NewCachesIter $lStatus]
    set lCachedObject [$lDesignCacheIter NextCachedObject $lStatus]
    set lPartName [DboTclHelper_sMakeCString]


    #Provide the loaction of OLB in which package should be copied.
    set lDestnLibPath [file normalize {C:\Users\LIBRARY2.OLB}]
    set lDsctnLibPathCstring [DboTclHelper_sMakeCString $lDestnLibPath]
    set lDestnLib [$lSession GetLib $lDsctnLibPathCstring $lStatus]
    # set lContLib [$lCachedLibObject GetContainingLib]
    # # set llibname [$lSession GetLib $lContLib $lStatus ]
    while {$lCachedObject != $lNullObj} {
    set lCachedLibObject [DboBaseObjectToDboLibObject $lCachedObject]
    set pkg [DboLibObjectToDboPackage $lCachedLibObject ]

    if {$pkg != $lNullObj} {

    $pkg GetName $lNameCString
    $lDestnLib CopyPackageAll $pkg $lNameCString $lStatus
    # puts [DboTclHelper_sGetConstCharPtr $lPartName]

    }


    set lCachedObject [$lDesignCacheIter NextCachedObject $lStatus]
    }
    # $lDestnLib MarkModified
    $lSession MarkAllLibForSave $lDestnLib
    $lSession SaveLib $lDestnLib
    $lSession RemoveLib $lDestnLib

    delete_DboDesignCachesIter $lDesignCacheIter

    Hope this will address your issue. Please let me know feedback.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
  • Jadystone
    0 Jadystone over 1 year ago in reply to CadAP

    Thank you very much. It works!

    • 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