• 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. PCB Design
  3. Capture tcl script to add/modify properties on all part...

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 167
  • Views 8139
  • Members are here 0
More Content
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Capture tcl script to add/modify properties on all parts

Jason Stubbs
Jason Stubbs over 10 years ago

I am a complete beginner on tcl scripts.  I have searched and failed to find any info on how to parse through a complete design and add a custom property onto all of the parts in a design.  The closest information I could find was in the OrCAD_Capture_TclTk_Extensions pdf. There is an example script that is on page 12:

proc addPropertyToAllPartsOnPage { pPage } {
set lNullObj NULL
set lStatus [DboState]
set pPartInstsIter [$pPage NewPartInstsIter $lStatus]
set pInst [$pPartInstsIter NextPartInst $lStatus]
# iterate over all parts
while {$pInst!=$lNullObj} {
set lPropNameCStr [DboTclHelper_sMakeCString "PartVersion"]
set lPropValueCStr [DboTclHelper_sMakeCString "1.1"]

#add the property to part
set lStatus [$pInst SetEffectivePropStringValue $lPropNameCStr $lPropValueCStr]
set pInst [$pPartInstsIter NextPartInst $lStatus]
}
delete_DboPagePartInstsIter $pPartInstsIter
$lStatus -delete
}

If I source this script in the command window and try to call it, I cannot pass any parameter to indicate the page (pPage).  I have tried simpler scripts that show other examples of procedures such as:

proc square {i} {
expr {$i*$i}
}

This works as expected in the command window, but the "addPropertyToAllPartsOnPage" proc does not.

The biggest problem I have is pressure on me to write this script by tomorrow. I'm scratching my head trying to work out what to do.

Any help  would be appreciated.

  • Cancel
  • oldmouldy
    oldmouldy over 10 years ago
    Look at page 29 of the PDF, you need to get a Capture Session, then get the designs within the Session, then get all the Schematics in the Design, then get all the pages in the Schematic(s), when you have the Page object(s), you can pass the Page objects into your script and work on them. Quite likely, the current Session and Active Design will suffice, look at the provided TCL working samples which will provide working examples of how to get these.
    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • Jason Stubbs
    Jason Stubbs over 10 years ago

    Oldmoldy, thanks.  

    I did manage to work this out over the last few days.  Your comments confirmed my assumptions.  There are a couple of things I cannot work out though.  

    1) my script searches all of the properties on a part until it finds the specific one I want to get the value from.  Since I know the name of the property I want to access, is there a way to get the value directly?  

    2)  when I first run the script on the design, it fails.  I think it is because the schematic that is open is not correctly focused by the script.  Is there a way to tell the script to point to the schematic? Maybe it has something to do with this function called "DboSession_GetDesignAndSchematics"?

    3) Finally, documentation on Cadence TCL functions is nonexistent.  Do you know of any other sources I can look at for help? Would a generic TCL language book help?

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • oldmouldy
    oldmouldy over 10 years ago
    Take a look in the capGenerateBOM.tcl example and the use of GetEffectivePropStringValue, takes a property name and returns the property value to the passed variable and a status to check. Take a look at registering your function to appear on a (pop-up) menu, it can be made to be available only in the correct context. Generic TCL has no real functions, even those that are pre-defined can be readily overridden by user definition, and there are plentiful resources on the internet that describe the TCL language facilities. The end of the TclTk extensions PDF documents the specific functions to access the Capture database, in terms of the parameters they take and return, by referencing the provided examples in the "cap" directories of tclscripts you can work out what the functions are expecting and how to invoke them. The main thing to watch is that TCL uses "plain strings" and the Capture database uses CStrings, specific to Microsoft C, so correct conversion is required to pass strings into the Capture functions and to retrieve the values for processing in TCL.
    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • adamsonj
    adamsonj over 6 years ago

    I know this is old, but I just found you can get the current page with:

    set activePage [GetActivePage]
    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • FrancoisD
    FrancoisD over 6 years ago in reply to adamsonj

    Great tip, thanks!

    • Cancel
    • Vote Up 0 Vote Down
    • 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