• 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 System Capture get ALL Custom Var from Project...

Stats

  • State Suggested Answer
  • Replies 10
  • Answers 1
  • Subscribers 15
  • Views 3618
  • Members are here 0
More Content

TCL Script System Capture get ALL Custom Var from Project and all from all Variants

PIPE
PIPE 7 months ago

Hello,

Sorry, i have search a lot but found nothing.

I must make some folders and my idea is to export via tcl all this information and with a exernal tool i read out this info and generate for every variant and master a sperate folder to but the bom etc inside.

Thanks for your help.

Peter

  • Cancel
  • Sign in to reply
Parents
  • CadAP
    0 CadAP 7 months ago

    @PIPE, Do you need command to read all custom variable and all variant name information?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • PIPE
    0 PIPE 7 months ago in reply to CadAP

    yes, and write them to a file

    Regards

    Peter

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • CadAP
    0 CadAP 7 months ago in reply to PIPE

     PIPE 

    for custom_var-> cps::getDirectives CUSTOMVAR --> Get list of all custom var in project.

    set lCustomVarlist [cps::getDirectives CUSTOMVAR ]

    foreach var $lCustomVarlist {

    set Val [ cps::getDirectiveValue CUSTOMVAR $var ]

    puts $Val

    }

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • PIPE
    0 PIPE 7 months ago in reply to CadAP

    hello,

    unfortinatly this works only for the customvar in the root not for variants

    Tcl> source c:/cadence/tcl/d.tcl

    GE

    <partno>

    <docno>

    <v>

    <date>

    <user>

    <title>

    BASE

    TAC290

    5865895SCH

    7

    P9

    7

    H

    in my variant i have change some customvar with the varianteditor

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • PIPE
    0 PIPE 7 months ago in reply to PIPE

    i have try this, but unfortinatly this prints a lot but no varinat customvars

    set filePath "c:/temp"
    set fileName "ProjectDetails.txt"
    set filePath1 [file join $filePath $fileName]
    set op [open $filePath1 "w+"]
    set sectionList [cps::getSections]
    foreach section $sectionList {
    set directiveList [cps::getDirectives $section]
    foreach directive $directiveList {
    set valueList [cps::getDirectiveValue $section $directive]
    set value1 [concat $section ":" $directive ":" $valueList]
    puts $op $value1
    }
    }
    close $op

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • MZ20250602835
    0 MZ20250602835 2 months ago in reply to CadAP

    Dear CadAP,

    may i ask how could i make a TCL/script in order to get the Custom variables variant specific Values for specific row(For example row3 DOC_PART_PCBA) and then give/transfer this value to a customer variables?

        

    Many thanks

    Moyan

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • PIPE
    0 PIPE 2 months ago in reply to MZ20250602835

    I unfortunately couldn't find a way  to read or write the changed customvariables from the variant editor.

    The only way was to export the variant.dat and read everything from it.

    I solved this, however, with an external tool I wrote, because I needed this information externally anyway.

    if you find a tcl solution, please post it.

    -Peter

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • PIPE
    0 PIPE 2 months ago in reply to MZ20250602835

    I unfortunately couldn't find a way  to read or write the changed customvariables from the variant editor.

    The only way was to export the variant.dat and read everything from it.

    I solved this, however, with an external tool I wrote, because I needed this information externally anyway.

    if you find a tcl solution, please post it.

    -Peter

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • CadAP
    0 CadAP 2 months ago in reply to PIPE

    PIPE MZ20250602835 

    Please use below code to get the custom variable name and value in list:


    proc getCustomVar {} {

    # puts "entering check mode"
    set toolVar [lindex [cps::getAppVersion] 0]

    set lDesigName [sch::dbGetRootDesignName]
    cpb::extractFile "worklib/$lDesigName/variant/variant.dat" {variant.dat}
    set filename "variant.dat"
    set pattern "CV_"
    set fp [open $filename r]
    set functiontest {}
    while {[gets $fp line] >= 0} {
    if {[string match -nocase "*$pattern*" $line]} {
    # puts $line
    lappend functiontest $line
    }
    }
    close $fp
    puts $functiontest
    if {[file exists $filename ] == 1} {

    file delete $filename

    }


    }

    getCustomVar

    You have two variants, V1 and V2, and the expected result is as below:



    **Expected Result:**


    { CV_V1 = 'TEST_V1=1236|TEST_V2=T_v1' ;} { CV_V2 = 'TEST_V1=T1|TEST_V2=T2' ;}

    Please do let me know your feedback.

    • Cancel
    • Vote Up +1 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