• 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. Function iterator optimization

Stats

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

Function iterator optimization

ZH202409115233
ZH202409115233 2 months ago

I have implemented a function designed to assign properties to specific components according to predefined rules. However, during execution, the memory usage continuously increases, eventually leading to a software crash. Could you please advise on potential optimization strategies?

code ;

proc parts_NCHandle_event_handle_dsn {} {
    set lStatus [DboState]
    set lSession $::DboSession_s_pDboSession
    DboSession -this $lSession
   
    set lDesign [$lSession GetActiveDesign]
    set NULL_OBJ "NULL"
   
    
    set lSchematicIter [$lDesign NewViewsIter $lStatus $::IterDefs_SCHEMATICS]
    while {[set lView [$lSchematicIter NextView $lStatus]] != $NULL_OBJ} {
        set lSchematic [DboViewToDboSchematic $lView]
        puts $lSchematic
        # 
        set lPagesIter [$lSchematic NewPagesIter $lStatus]
        while {[set lPage [$lPagesIter NextPage $lStatus]] != $NULL_OBJ} {
            # 
            puts $lPage
            set lPartInstsIter [$lPage NewPartInstsIter $lStatus]
            while {[set lInst [$lPartInstsIter NextPartInst $lStatus]] != $NULL_OBJ} {
                set lPlacedInst [DboPartInstToDboPlacedInst $lInst]
                if {$lPlacedInst != $NULL_OBJ} {
                    if {[catch {
                        setNC $lPlacedInst
                    } err]} {
                        puts " $lPlacedInst : $err"
                    }
                }
            }
            delete_DboPagePartInstsIter $lPartInstsIter
            DboTclHelper_sEvalPage $lPage
        }
        delete_DboSchematicPagesIter $lPagesIter
    }
    puts "执行完成"
    delete_DboLibViewsIter $lSchematicIter
    $lStatus -delete
}
proc setNC {lPlacedInst} {
set lStatus [DboState]
set lNullObj NULL
# puts $lcolor
set lPropNameCStr [DboTclHelper_sMakeCString "Value"]
#DboDisplayProp
set pDispProp [$lPlacedInst GetDisplayProp $lPropNameCStr $lStatus]
# puts $pDispProp
if {$pDispProp != $lNullObj} {
set lvalue [DboTclHelper_sMakeCString]
set lStatus [$pDispProp GetValueString $lvalue]
set lvStr [DboTclHelper_sGetConstCharPtr $lvalue]
DboTclHelper_sDeleteCString $lvalue
# puts $lvStr
set str ""
if {![string match "NC/*" $lvStr ] } {
# puts ookk11
set lcolor [$lPlacedInst GetColor $lStatus]
if {$lcolor == 45} {
set str "NC/"

} elseif {$lcolor == 43} {
set str "NC/NC/"
}
}
if {$str != ""} {
# puts $str$lvStr
set lPropValueCStr [DboTclHelper_sMakeCString $str$lvStr]
set lStatus [$lPlacedInst SetEffectivePropStringValue $lPropNameCStr $lPropValueCStr 0]
}
}

set lPropsIter [$lPlacedInst NewDisplayPropsIter $lStatus]
#set lNullObj NULL
set lvalue [DboTclHelper_sMakeCString]
#puts 1
set lPropNameCStr [DboTclHelper_sMakeCString "Value"]
#DboDisplayProp
set pDispProp [$lPlacedInst GetDisplayProp $lPropNameCStr $lStatus]
DboTclHelper_sDeleteCString $lPropNameCStr
if {$pDispProp != $lNullObj } {
set lStatus [$pDispProp GetValueString $lvalue]
set lvStr [DboTclHelper_sGetConstCharPtr $lvalue]
if {![regexp {^NC/[^N]} $lvStr]} {

return
}
if {![string match "NC/NC/*" $lvStr ]} {

return
}

#puts $lvalue
#get the first display property on the object
set lDProp [$lPropsIter NextProp $lStatus]
while {$lDProp !=$lNullObj } {

#
set lPropNameCStr [DboTclHelper_sMakeCString "Color"]
if {[regexp {^NC/[^N]} $lvStr]} {
set lPropValueCStr [DboTclHelper_sMakeCString "RGB(192,192,192)"]
set lStatus1 [$lPlacedInst SetEffectivePropStringValue $lPropNameCStr $lPropValueCStr]
$lDProp SetColor 45
}
if {[string match "NC/NC/*" $lvStr ]} {
set lPropValueCStr [DboTclHelper_sMakeCString "RGB(128,128,128)"]
set lStatus1 [$lPlacedInst SetEffectivePropStringValue $lPropNameCStr $lPropValueCStr]
$lDProp SetColor 43
}
DboTclHelper_sDeleteCString $lPropNameCStr
#get the next display property on the object
set lDProp [$lPropsIter NextProp $lStatus]
}
delete_DboDisplayPropsIter $lPropsIter
}
DboTclHelper_sDeleteCString $lvalue
$lStatus -delete
puts "done"
}
  • Cancel
  • Sign in to reply
  • PatEscher
    0 PatEscher 2 months ago in reply to PatEscher

    looks like the only way is to follow this article

    How to enable/disable Online DRC using Tcl script commands in Capture CIS

    not nice, but I guess that this is the only way how to do it and modify the local DRC settings. Just hoping that this does not lead to a modification to the design itself

    • 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