• 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 set a property value in all titleblocks in...

Stats

  • State Verified Answer
  • Replies 3
  • Answers 1
  • Subscribers 13
  • Views 285
  • Members are here 0
More Content

TCL script to set a property value in all titleblocks in a hierarchical design

Willy
Willy 10 days ago

I am attempting to write a TCL script that will set/update Title Block values in all Title Blocks in a schematic design.

I have been working through the OrCAD_Capture_TclTk_Extensions.pdf doc and googling. I can get the TCL script to find and run through all pages, but when I try to set or get property values I keep getting various errors depending on which examples/methods I am using.

I removed the prompting for values and just hard coded in a propName of YEAR (which definitely exists in all sheets/pages) to propValue of 2020 to make the script shorter/simpler for getting help. I have left in commented out different things I have tried.

Any help much appreciated, script below:

# Define the property name and new value
set propName "YEAR"
set propValue "2020"

set lDesign [GetActivePMDesign]
set lStatus [DboState]
set lNullObj NULL

# 2. Iterate through Schematic Folders

set lSchi_Name [DboTclHelper_sMakeCString]

if {$lDesign != $lNullObj} {

set lSchematicIter [$lDesign NewViewsIter $lStatus $::IterDefs_SCHEMATICS]
#get the first schematic view
set lView [$lSchematicIter NextView $lStatus]
puts $lSchematicIter
set lPage_Name [DboTclHelper_sMakeCString]
puts $lPage_Name

while { $lView != $lNullObj} {
#dynamic cast from DboView to DboSchematic
set lSchematic [DboViewToDboSchematic $lView]
$lSchematic GetName $lSchi_Name
set lPagesIter [$lSchematic NewPagesIter $lStatus]
#get the first page
set lPage [$lPagesIter NextPage $lStatus]

puts [DboTclHelper_sGetConstCharPtr $lSchi_Name]

while {$lPage!=$lNullObj} {
#placeholder: do your processing on $lPage

$lPage GetName $lPage_Name
puts [DboTclHelper_sGetConstCharPtr $lPage_Name]

# set lTitleBlocksIter [$lPage NewTitleBlocksIter $lStatus]
# set lTitle [$lTitleBlocksIter NextTitleBlock $lStatus]
#while {$lTitle!=$lNullObj} {
#placeholder: do your processing on $lTitle
#puts $lTitle

# set lStatus [$lTitle SetEffectivePropStringValue "YEAR" "1999"]
#set lStatus [$lTitle GetEffectivePropStringValue "YEAR" $propValue]
# $lTitle GetEffectivePropStringValue $propName propValue

#puts "Property Value: $propValue"

#get the next title block
#set lTitle [$lTitleBlocksIter NextTitleBlock $lStatus]
#}
#delete_DboPageTitleBlocksIter $lTitleBlocksIter
set pValue ""

# 3. Get the value of a specific property (e.g., "Title")
# GetEffectivePropStringValue takes (PropertyName, VariableToStoreValue)
set lStatus [$lPage GetEffectivePropStringValue "Title" pValue]

# 4. Check status and print result
if {$lStatus == 1} {
puts "Title Block Value: $pValue"
} else {
puts "Property 'Title' not found."
}
set lPage [$lPagesIter NextPage $lStatus]
}
#placeholder: do your processing on $lSchematic
#puts $lSchematic
#get the next schematic view
set lView [$lSchematicIter NextView $lStatus]
}
delete_DboLibViewsIter $lSchematicIter
delete_DboSchematicPagesIter $lPagesIter
}

  • Cancel
  • Sign in to reply
  • TechnoBobby
    0 TechnoBobby 10 days ago

    Hi Willy ,

    Please try the TCL script below to update properties in all title blocks. For hierarchical designs, it’s important to get the occurrence of title block. Also, for both Get or SetEffectivePropStringValue, the property name and value must be passed as CStrings.

    Hope it helps!

    proc lGetOcc {lParent} {
    set lPartOcc {}
    set lOccCount [$lParent GetOccurrencesCount]
    for {set i 0} {$i < $lOccCount} {incr i} {
    set lOcc [$lParent GetOccurrencesAtPos $i]
    lappend lPartOcc $lOcc
    }
    return $lPartOcc
    }

    proc lUpdateTitleBlocksOnPage {lPage lPropNameCString lPropValueCString} {

    set lNullObj NULL
    set lStatus [DboState]

    # Iterate title blocks on this page
    set lTitleBlocksIter [$lPage NewTitleBlocksIter $lStatus]
    set lTitleBlock [$lTitleBlocksIter NextTitleBlock $lStatus]

    while {$lTitleBlock != $lNullObj} {

    # For hierarchical designs / "yellow fields", update occurrences
    set lOccList [lGetOcc $lTitleBlock]

    if {[llength $lOccList] > 1} {
    foreach lOcc $lOccList {
    set lStatus [$lOcc SetEffectivePropStringValue $lPropNameCString $lPropValueCString]
    }
    } else {
    # Flat case: update title block directly
    set lStatus [$lTitleBlock SetEffectivePropStringValue $lPropNameCString $lPropValueCString]
    }
    set lTitleBlock [$lTitleBlocksIter NextTitleBlock $lStatus]
    }
    delete_DboPageTitleBlocksIter $lTitleBlocksIter
    }

    proc UpdateAllTitleBlocksInDesign {propName propValue} {

    set lNullObj NULL
    set lStatus [DboState]

    # Get the session and active design
    set lSession $::DboSession_s_pDboSession
    DboSession -this $lSession
    set lDesign [$lSession GetActiveDesign]

    if {$lDesign == $lNullObj} {
    puts "ERROR: No active design."
    return
    }

    # Convert property name/value to CStrings
    set lPropNameCString [DboTclHelper_sMakeCString $propName]
    set lPropValueCString [DboTclHelper_sMakeCString $propValue]

    # For logging
    set lSchi_Name [DboTclHelper_sMakeCString]
    set lPage_Name [DboTclHelper_sMakeCString]

    # Iterate schematics
    set lSchematicIter [$lDesign NewViewsIter $lStatus $::IterDefs_SCHEMATICS]
    set lView [$lSchematicIter NextView $lStatus]

    while {$lView != $lNullObj} {

    set lSchematic [DboViewToDboSchematic $lView]
    $lSchematic GetName $lSchi_Name

    # Iterate pages
    set lPagesIter [$lSchematic NewPagesIter $lStatus]
    set lPage [$lPagesIter NextPage $lStatus]

    while {$lPage != $lNullObj} {

    $lPage GetName $lPage_Name

    # Optional logging
    # puts "Updating: [DboTclHelper_sGetConstCharPtr $lSchi_Name] / [DboTclHelper_sGetConstCharPtr $lPage_Name]"

    # Update all title blocks on this page (flat + occurrences)
    lUpdateTitleBlocksOnPage $lPage $lPropNameCString $lPropValueCString

    set lPage [$lPagesIter NextPage $lStatus]
    }
    delete_DboSchematicPagesIter $lPagesIter
    set lView [$lSchematicIter NextView $lStatus]
    }
    delete_DboLibViewsIter $lSchematicIter

    puts "Done. Updated Title Block property '$propName' to '$propValue' everywhere."
    }

    UpdateAllTitleBlocksInDesign "YEAR" "2020"

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • Willy
    +1 Willy 10 days ago in reply to TechnoBobby

    That is nothing like what I expected to see, thanks very much!

    I will see how I go adding the prompts and other variables back in.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
  • Willy
    0 Willy 10 days ago in reply to Willy

    Hey TechnoBobby, one small issue is that it doesn't work on occurrences (the yellow highs). Not as issue for my usage at the moment but I noticed you had that implementation in your code

    • 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.

© 2026 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information