• 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. Exporting variants.lst through tcl or automation

Stats

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

Exporting variants.lst through tcl or automation

PatEscher
PatEscher over 1 year ago

Hello, 

is there any way to export the variants.lst file through either tcl code, a command or any other utility, so that we can automate this process?
as of today, this has to be done manually through the Part Manager UI, and this is quite error prone as the users are missing this a lot and the variants.lst is either then not available or not up to date in Allegro

Thanks

Patrick

  • Sign in to reply
  • Cancel
  • Jeet
    0 Jeet over 1 year ago

    Try using following steps:

    1. Enable Journaling and Display Commands from Extended Preferences > Command Shell.
    2. Now, select and right click on the design file in the project manager and open Part Manager.
    3. Copy MenuCommand number from the command window and replace it in the below code in place of 14604 >

    set lSession $::DboSession_s_pDboSession
    DboSession -this $lSession
    set lNullObj NULL
    set lDesign [$lSession GetActiveDesign]
    if { $lDesign != $lNullObj} {
    MenuCommand "14604"
    Menu "Tools::Export Variant List"
    return
    }


    4. Run the TCL script in the command window and Hit Export it will create variants.lst file.

    Hope this helps!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • PatEscher
    0 PatEscher over 1 year ago in reply to Jeet

    Hello Vishwajeet, 
    unfortunately this brings up the UI which requires a user input.

    I am looking for a full automation, so without User Input.
    is there a possibility to control the UI also through an xml file, like when switching to the variant view (even if controlling the UI is not really a good practice :)

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • CadAP
    0 CadAP over 1 year ago in reply to PatEscher

    Hi Pat,

    Please use the below tcl code. It will generate one file with name VariantBom.txt active directory (pwd command used to check the active directory).

    Generate file contains the similar information as in variant.lst file (like variant name , All parts form group and Subgroup(if part of a variant)).

    proc dumpVarinatsubBoms {BomSubgGroupNameList} {
    set lNullObj "NULL"
    set fileReport [open "VariantBom.txt" a+]
    set lDesign [GetActivePMDesign]
    set lCISDesign [CPartMgmt_GetCisDesign $lDesign]
    set variantBomCNewBOm [$lCISDesign GetBOMVariantContainer]
    set VariantBomCount [$variantBomCNewBOm GetBomCount]
    # $lCISDesign GetGroupsContainer
    set CVariants [$lCISDesign GetGroupsContainer]
    # puts [$CVariants GetGroupCount]
    set lAllGroupCSArray [CISTclHelper_sMakeCStringArray]
    $CVariants GetAllGroups $lAllGroupCSArray
    set lGroupCount [$CVariants GetGroupCount]
    set lGetSubGroupCString [DboTclHelper_sMakeCString]
    # puts "$lAllGroupCSArray"
    # puts "$lGroupCount"
    set lAllCommonParts [CISTclHelper_sMakeCUIntArray]
    # puts $lPartsCount
    $lCISDesign GetCommonParts $lAllCommonParts
    set lAllCommonPartsCount [CISTclHelper_sGetCUIntArraySize $lAllCommonParts]
    for {set z 0} {$z < $lGroupCount} {incr z} {
    set lGroupNameCString [CISTclHelper_sGetCString $lAllGroupCSArray $z]
    set lAllSubGroupCSArray [CISTclHelper_sMakeCStringArray]
    # puts $lGroupNameCString
    set lGroupName [DboTclHelper_sGetConstCharPtr $lGroupNameCString]
    # puts $lGroupName
    set lSubGroupCount [$CVariants GetSubGroupCount $lGroupNameCString]
    # puts $lSubGroupCount
    if {$lSubGroupCount > 0} {
    set subgrouplist {}
    set lGetSubGroup [$CVariants GetAllSubGroup $lGroupNameCString $lAllSubGroupCSArray ]
    # set lSubGroupCount [$CVariants GetSubGroupCount $lGroupNameCString]

    for {set k 0} {$k <$lSubGroupCount} {incr k} {

    set lSubGroupNameCString [$CVariants GetSubGroupByIndex $lGroupNameCString $k]
    set lSubGroupName1 [DboTclHelper_sGetConstCharPtr $lSubGroupNameCString]
    lappend subgrouplist $lGroupName\_$lSubGroupName1
    }
    }
    if {$lSubGroupCount == 0} {

    set subgrouplist {}

    }
    # puts [$variantBomCNewBOm IsGroupInBom $lGroupNameCString]
    if {[$variantBomCNewBOm IsGroupInBom $lGroupNameCString] == 1 && [lsearch $BomSubgGroupNameList $lGroupName ] > -1} {

    set lAllGroupParts [CISTclHelper_sMakeCUIntArray]

    $CVariants GetPartsFromGroup $lGroupNameCString $lAllGroupParts
    set lPartsCount [CISTclHelper_sGetCUIntArraySize $lAllGroupParts]
    # puts $lPartsCount
    # puts "+++++ VariantBomName:$VarinatName +++++++++"
    # puts "==========Group:=$lGroupName =========="
    puts $fileReport "==========Group:=$lGroupName =========="
    for {set y 0} {$y < $lPartsCount} {incr y} {
    set partNumber [DboTclHelper_sMakeCString "Part_Number"]
    set lPartId [CISTclHelper_sGetUInt $lAllGroupParts $y]
    # puts $lPartId
    if {$lPartId != 0 } {
    # set lSubGroupName [DboTclHelper_sMakeCString ""]
    set lUINTPartId [CISTclHelper_sGetUINTFromInt $lPartId]
    set lCISInstOcc [$lCISDesign GetPartOccForID $lUINTPartId]
    set lCispatInst [$lCISInstOcc GetOwningCISPartInst]
    set lRefDes [$lCISInstOcc GetPartRefDes]
    set lRefDes [$lRefDes GetRefDes]
    set lRefDes [DboTclHelper_sMakeCString $lRefDes]
    set lRefDesStr [DboTclHelper_sGetConstCharPtr $lRefDes]
    # puts $lRefDesStr
    puts $fileReport $lRefDesStr
    }
    }
    }


    foreach subgrp $subgrouplist {
    # puts $subgrp
    set lGroupNameCString1 [DboTclHelper_sMakeCString $subgrp]
    set lStringindex [string last "_" $subgrp]
    set lSubGroupName [string range $subgrp [expr {$lStringindex + 1}] end]
    set lSubGroupNameCS [DboTclHelper_sMakeCString $lSubGroupName]
    # puts $lSubGroupName
    # puts [$variantBomCNewBOm IsGroupInBom $BomSubgGroupName]
    if {[$variantBomCNewBOm IsGroupInBom $lGroupNameCString1] == 1 && [lsearch $BomSubgGroupNameList $subgrp ] > -1 } {

    # set lNullObj "NULL"
    set lSubGroupPart [CISTclHelper_sMakeCUIntArray]
    # set lSubGroupName [$CVariants GetSubGroupByIndex $lGroupNameCString $x]
    $CVariants GetPartsFromSubGroup $lGroupNameCString $lSubGroupNameCS $lSubGroupPart
    set lSubPartsCount [CISTclHelper_sGetCUIntArraySize $lSubGroupPart]
    # puts "==========SubGroup:= $subgrp ========="
    puts $fileReport "==========SubGroup:= $subgrp ========="
    for {set i 0} {$i < $lSubPartsCount} {incr i} {

    # set partNumber [DboTclHelper_sMakeCString "Part_Number"]

    set lPartId [CISTclHelper_sGetUInt $lSubGroupPart $i]
    # puts $lPartId
    if {$lPartId != 0 } {
    set lSubGroupName [DboTclHelper_sMakeCString ""]
    set lUINTPartId [CISTclHelper_sGetUINTFromInt $lPartId]
    set lCISInstOcc [$lCISDesign GetPartOccForID $lUINTPartId]
    if { $lCISInstOcc != $lNullObj } {
    set lRefDes [$lCISInstOcc GetPartRefDes]
    set lRefDes [$lRefDes GetRefDes]
    set lRefDes [DboTclHelper_sMakeCString $lRefDes]
    set lRefDesStr [DboTclHelper_sGetConstCharPtr $lRefDes]
    # puts $lRefDesStr
    puts $fileReport $lRefDesStr
    }
    }

    }

    }
    }

    # puts $subgroup
    # delete_CISInstOccurrence $lCISInstOcc
    if {[$variantBomCNewBOm IsGroupInBom $lGroupNameCString] == 1 && [lsearch $BomSubgGroupNameList $lGroupName ] > -1} {
    # puts "==============BASE PART/COMMON_PART=============="
    puts $fileReport "==============BASE PART/COMMON_PART=============="
    for {set i 0} {$i<$lAllCommonPartsCount} {incr i} {

    set lPartId1 [CISTclHelper_sGetUInt $lAllCommonParts $i]
    # puts $lPartId1
    if {$lPartId1 != 0 } {
    set lSubGroupName [DboTclHelper_sMakeCString ""]
    set lUINTPartId1 [CISTclHelper_sGetUINTFromInt $lPartId1]
    set lCISInstOcc1 [$lCISDesign GetPartOccForID $lUINTPartId1]
    set lRefDes [$lCISInstOcc1 GetPartRefDes]
    # puts $lRefDes
    set lRefDes [$lRefDes GetRefDes]
    set lRefDes [DboTclHelper_sMakeCString $lRefDes]
    set lRefDesStr [DboTclHelper_sGetConstCharPtr $lRefDes]
    # puts $lRefDesStr
    puts $fileReport $lRefDesStr
    }
    }
    }
    }
    delete_CISInstOccurrence $lCISInstOcc
    close $fileReport
    }

    set lNullObj "NULL"
    set lDesign [GetActivePMDesign]
    set lCISDesign [CPartMgmt_GetCisDesign $lDesign]
    set variantBomCNewBOm [$lCISDesign GetBOMVariantContainer]
    set lVarinatBomCSS [CISTclHelper_sMakeCSStringArray]
    # set lVarinatBomCS [CISTclHelper_sMakeCStringArray]
    set lBomList [$variantBomCNewBOm GetBomVariants $lVarinatBomCSS]
    # set lBomReport [open "VariantBom.txt" a+]
    if {[file exists "VariantBom.txt"] == 1} {

    set foo [open "VariantBom.txt" w+]

    }
    set lCSSArraySize [CISTclHelper_sGetCStringArraySize $lVarinatBomCSS]
    set VbomList {}
    for {set i 0} {$i < $lCSSArraySize} {incr i} {
    set VbomList {}
    set lBomReport [open "VariantBom.txt" a+]
    set bomlist {}
    set lVarinatBomCS [CISTclHelper_sMakeCStringArray]
    set lBomDataCS [CISTclHelper_sGetCString $lVarinatBomCSS $i]
    # set VbomList [lreplace $VbomList 0 end "" ]
    # set bomList {}
    # puts "+++++++++ BOM_Variant_Name:== [DboTclHelper_sGetConstCharPtr $lBomDataCS] ++++++++++"
    puts $lBomReport "+++++++++ BOM_Variant_Name:== [DboTclHelper_sGetConstCharPtr $lBomDataCS] ++++++++++"
    set lBomData [DboTclHelper_sGetConstCharPtr $lBomDataCS]
    $variantBomCNewBOm GetBomGroups $lBomDataCS $lVarinatBomCS
    set lArraySize [CISTclHelper_sGetCStringArraySize $lVarinatBomCS]
    for {set z 0} {$z < $lArraySize} {incr z} {
    set lVbomData {}
    set lVbomData [CISTclHelper_sGetCString $lVarinatBomCS $z]
    lappend VbomList [DboTclHelper_sGetConstCharPtr $lVbomData]

    }
    close $lBomReport
    dumpVarinatsubBoms $VbomList

    }

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • PatEscher
    0 PatEscher over 1 year ago in reply to CadAP

    Hello, 

    Thank you for the code. Unfortunately it is not exactly what we need.
    dumping out the BOM's of the variants etc. is what we do already.

    We really look for a way to fully automate the export of the variant.lst file from Capture to Allegro PCB Editor so that the variant information is available in Allegro PCB.
    So we would need to have exactly the same syntax understood by allegro than when going through the the export Variant.LST in Part Manager

    Thanks

    Patrick

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Jeet
    +1 Jeet over 1 year ago in reply to PatEscher

    Try using the following TCL Code >

    set lSession $::DboSession_s_pDboSession
    DboSession -this $lSession
    set lNullObj NULL
    set lDesign [$lSession GetActiveDesign]
    if { $lDesign != $lNullObj} {
    MenuCommand "14604"
    SetAutomationFlag 1
    "ExportVariantList" C:/TCL1 C:/Cadence/SPB_23.1/tools/capture/
    SetAutomationFlag 0
    }


    Make sure the path variant.lst should have read/write permissions.
    "ExportVariantList" <path to dump variant.lst> <path to variant.cfg file>

    Let me know how it goes for you after performing the steps, are you able to generate variants.lst with tcl?

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

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

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