• 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 check the property of component in system...

Stats

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

TCL Script to check the property of component in system capture.

MZ20250602835
MZ20250602835 1 day ago

Dear all,

i try to make a tcl script to looks up components on each page in system capture. If a component has the property VAR_1, it enters the VAR_1 variant view(i created a variant with name VAR_1), marks that component as Do Not Install (DNI), and cleanly exits the variant view using variantOFF.

the following is my codes: unfortunately it does`t work may i ask how could i correct these codes to make it work? many thanks Moyan.

# #############################################################################
# setSelfToDNI
# This procedure looks up components on each page. If a component has the
# property VAR_1, it enters the VAR_1 variant view context, marks that component
# as Do Not Install (DNI), and cleanly exits the variant context using variantOFF.
# #############################################################################

proc setSelfToDNI {} {
# 1. Initialize environment settings and Batch Mode matching your master structure
sch::enterBatchMode

# Optional structure hook: Configure project settings to keep variant structures active
configureProjectExp -variant true
configureProjectExp -blocks true
configureProjectExp -library false

# 2. Get all page information using the schPageUtils structural format
set pageInfoAll [schPageUtils::getDesignPagesAllInfo]
set pageSize [schPageUtils::getPagesInfoSize $pageInfoAll]

puts "--- STARTING STRUCTURAL DNI COMPONENT SCAN ---"
puts "Total project pages to process: $pageSize"

# 3. Iterate over each sheet using the exact loop constraint from your master code
for {set i 1} {$i <= $pageSize} {incr i} {

set viewId [schPageUtils::getPageId $pageInfoAll $i]
set pageName [schPageUtils::getPageName $pageInfoAll $i]

puts "Opening page context: $pageName"
openItem $viewId SCH PAGE

set pageId [sch::dbGetActivePage]
set itemId [sch::dbGetPageItems $pageId]

# 4. Traverse canvas objects on the active page
foreach item $itemId {

# Extract the user-facing text label identifier (RefDes text block)
set compRefDes ""
catch {
set compRefDes [sch::dbGetItemText $item]
}

# If the item doesn't contain reference designator text context, pass it
if {$compRefDes eq ""} {
continue
}

# Map the graphical item pointer directly to its root logical block definition
set compInst ""
catch {
set compInst [sch::dbGetCompInst $item]
}
if {$compInst eq ""} {
continue
}

# 5. Look up the presence of the target VAR_1 property on the logical instance block
set hasVar1 0
set var1Value ""

if {![catch {
set var1Value [sch::dbGetPropValue $compInst VAR_1]
}]} {
if {$var1Value ne ""} {
set hasVar1 1
}
}

# 6. If match is verified, execute your variant isolation and toggle pipeline
if {$hasVar1} {
puts " -> Found Component $compRefDes on $pageName with VAR_1 property."

# Step A: Jump into the targeted "VAR_1" variant viewing perspective
puts " Entering variant view context via 'viewVariant -variant VAR_1'..."
if {[catch {viewVariant -variant VAR_1} err]} {
puts " [Warning] Failed to switch to variant view mode 'VAR_1': $err"
continue
}

# Step B: Re-instantiate the canvas window pointer inside the variant configuration plane
openItem $viewId SCH PAGE

# Step C: Isolate and highlight the target element matching your selection framework
unselectObject -all
sch::dbSelectObjectById $item $sch::DBTrue

# Step D: Apply the structural property change marking the part to Do Not Install
if {[catch {setDNI -variant VAR_1 -comp $compRefDes -state true} err]} {
puts " [Warning] Could not flag component $compRefDes as DNI: $err"
} else {
puts " [Success] Component $compRefDes successfully marked DNI inside VAR_1."
}

# Step E: Safely step back into the base schematic workspace via variantOFF as requested
puts " Exiting variant tracking context via 'variantOFF'..."
if {[catch {variantOFF} err]} {
puts " [Warning] Failed to execute structural command variantOFF: $err"
}

# Step F: Reopen the base schematic context so downstream loops keep valid data pointers
openItem $viewId SCH PAGE
}
}

# 7. Close and cycle the page context matching your structural pattern
closeItem $viewId
}

# 8. Commit changes globally and finalize execution
saveAll
sch::leaveBatchMode
puts "--- COMPLETED DNI TRACKING PIPELINE SUCCESSFUL ---"
}

  • Sign in to reply
  • Cancel

Top Replies

  • MZ20250602835
    MZ20250602835 1 day ago +1 verified
    Dear all, i found the solution How to filter components based on a specific property, add those components to a variant, and mark them as DNI
  • MZ20250602835
    +1 MZ20250602835 1 day ago

    Dear all,

    i found the solution

    How to filter components based on a specific property, add those components to a variant, and mark them as DNI

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

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

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