• 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. OrCAD Capture CIS: Export BOM via TCL

Stats

  • State Suggested Answer
  • Replies 5
  • Answers 1
  • Subscribers 13
  • Views 4247
  • Members are here 0
More Content

OrCAD Capture CIS: Export BOM via TCL

ggeorgg
ggeorgg over 2 years ago

Hello, 

I want to get the BOM for one or multiple CIS variants via TCL to be able to push it to SAP directly from OrCAD.

I found the "CVariant_GetPartsFromAllVariants" method, but I need some assistance on how I can loop over all its elements. Here is what I have already tried:

set DboDesign [GetActivePMDesign]
set CISDesign [CPartMgmt_GetCisDesign $DboDesign]
set CVariantGroupsContainer [CISDesign_GetGroupsContainer $CISDesign]
set QUIntArrayPartsFromAllVariants [QUIntArray]
set int [CVariant_GetPartsFromAllVariants $CVariantGroupsContainer $QUIntArrayPartsFromAllVariants]

set QUIntArrayUpperBound [QUIntArray_GetUpperBound $QUIntArrayPartsFromAllVariants]
set UInt [QUIntArray_GetAt $QUIntArrayPartsFromAllVariants $QUIntArrayUpperBound]
set UInt [QUIntArray_ElementAt $QUIntArrayPartsFromAllVariants $QUIntArrayUpperBound]

CISTclHelper_sGetIntFromUINT $UInt

It seems the last command returns the OccID of the "last" part in the design. Now I would like to iterate over all elements in $QUIntArrayPartsFromAllVariants, but I need to somehow create an INT_PTR manually. How can I do that?

Similar problem with the method "CNewBOm_GetAllParts"

set BOMVariantContainer [CISDesign_GetBOMVariantContainer $CISDesign]
set QUIntArrayAllParts [QUIntArray]
set int [CNewBOm_GetAllParts $BOMVariantContainer $QUIntArrayAllParts]
set QUIntArrayUpperBound [QUIntArray_GetUpperBound $QUIntArrayAllParts]
set UInt [QUIntArray_GetAt $QUIntArrayAllParts $QUIntArrayUpperBound]
set UInt [QUIntArray_ElementAt $QUIntArrayAllParts $QUIntArrayUpperBound]

CISTclHelper_sGetIntFromUINT $UInt

So the question is, how can I iterate a QUIntArray? Or is there currently no way to iterate those type of arrays and I have to use a different method? Which one would be suited/best?

  • Sign in to reply
  • Cancel
  • CadAP
    0 CadAP over 2 years ago

    #Hi ggeorgg, I have created a sample tcl which will dump all variant name with component refdes under that variant in a DumpVaraintBom.txt file at current active project. You can modify to add more information according to your requirements.


    #Please refer the tcl document present at cadence installed hierarchy <Cadence_installed_hierarchy>\tools\capture\tclscripts\OrCAD_Capture_TclTk_Extensions.pdf

    set DboDesign [GetActivePMDesign]
    set CISDesign [CPartMgmt_GetCisDesign $DboDesign]
    set CVariantGroupsContainer [$CISDesign GetBOMVariantContainer]
    set fp [open "DumpVaraintBom.txt" a+]
    set bomCount [$CVariantGroupsContainer GetBomCount]
    # puts $bomCount
    for {set i 0} {$i < $bomCount} {incr i} {

    set partArray [CISTclHelper_sMakeCUIntArray]
    set groupName [DboTclHelper_sMakeCString]
    $CVariantGroupsContainer GetBomName $i $groupName
    set partInt [$CVariantGroupsContainer GetPartsFromBom $groupName $partArray]
    set grName [DboTclHelper_sGetConstCharPtr $groupName]
    set arraySize [CISTclHelper_sGetCUIntArraySize $partArray]
    puts $arraySize
    puts $fp "+++++====VariantName:=$grName====+++++"
    for {set y 0} {$y <=$arraySize} {incr y} {

    set lPartId [CISTclHelper_sGetUInt $partArray $y]
    if {$lPartId != 0} {
    set lUINTPartId [CISTclHelper_sGetUINTFromInt $lPartId]
    # puts $lUINTPartId
    set lCISInstOcc [$CISDesign GetPartOccForID $lUINTPartId]
    # puts $lCISInstOcc
    if {$lCISInstOcc != "NULL"} {

    set lRefDes [$lCISInstOcc GetPartRefDes]
    set lRefDes [$lRefDes GetRefDes]
    set lRefDes [DboTclHelper_sMakeCString $lRefDes]
    set lRefDesStr [DboTclHelper_sGetConstCharPtr $lRefDes]
    puts $fp "$lRefDesStr"
    }
    }

    }

    }

    close $fp


    Hope this helps!

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • ggeorgg
    0 ggeorgg over 2 years ago in reply to CadAP

    Thanks, the code is working as expected, but what about catching errors?

    What happens if a user forgot to assign all components/groups to a variant? Is it possible to check this as well? I guess it is possible with the method "GetAmbiIds". Have you already used it?

    Or what happens if a user accidentially assigns a reference designator which is already present in the design manually to a component and forgets to check it again. Is it sufficient to create a list of already written RefDes and to compare if a new RefDes is already present in the list of RefDes?

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • CadAP
    0 CadAP over 2 years ago in reply to ggeorgg

    Hi ggeorgg,

    To compare the parts:

    1.GetAllParts from GetBOMVariantContainer
    2.GetPartsFromGroup(each group) from GetGroupsContainer.

    To compare the groups:

    1.GetBomGroups (each varaint) from GetBOMVariantContainer.
    2.GetAllGroups from GetGroupsContainer.


    Or what happens if a user accidentially assigns a reference designator which is already present in the design manually to a component and forgets to check it again. Is it sufficient to create a list of already written RefDes and to compare if a new RefDes is already present in the list of RefDes?

    Ans : Please check the DRC rule  for "Report identical part reference."

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • ggeorgg
    0 ggeorgg over 2 years ago in reply to CadAP

    Thanks for the hint. I tried this and yes, it can help in case the user did assign the same reference designator twice on the schematic but it does not detect errors in group/subgroup assignements in the part manager. 

    I have seen users who copy part from the core (first line in part manager) to groups. Like this it is possible, that the same part is present in a variant twice. The part manager directly shows the "Ambigous: Undefined" in the "Part Status" column. 

    So the question is, how can I easily check these kind of errors?

    I tried this without success:

    set DboDesign [GetActivePMDesign]
    set CISDesign [CPartMgmt_GetCisDesign $DboDesign]

    set CVariantGroupsContainer [CISDesign_GetGroupsContainer $CISDesign]
    set CAmbiguousParts [CVariant_GetAmbiguousPartsContainer $CVariantGroupsContainer]

    set BOMName_CString [DboTclHelper_sMakeCString "Variante 3"]
    set Id 0
    CAmbiguousParts_GetPartsCount $CAmbiguousParts $BOMName_CString [CISTclHelper_sGetUINTFromInt $Id]

    Do you have further hints?

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • CadAP
    0 CadAP over 2 years ago in reply to ggeorgg

    Hi ggeorge,

    #Below tcl will help you to get the list of components refdes occurrence more than once in Variant.

    #This will help you to find which refdes are repeated.

    # Similarly, you can get all the properties and values and do the comparison to get the repeated components information.

    #Section "Get all the prop and its value for an lCISInstOcc" is commented you can uncomment and do the changes as per your need

    set DboDesign [GetActivePMDesign]
    set CISDesign [CPartMgmt_GetCisDesign $DboDesign]
    set propValueList {}
    set newvalueList {}
    set refdesList {}
    # set CVariantGroupsContainer [CISDesign_GetGroupsContainer $CISDesign]
    set CVariantGroupsContainer [CISDesign_GetBOMVariantContainer $CISDesign]
    # puts [$CVariantGroupsContainer GetGroupCount]
    # set groupSzie [$CVariantGroupsContainer GetGroupCount]
    # puts $groupSzie
    set QUIntArrayPartsFromAllVariants [QUIntArray]
    # puts "[CISTclHelper_sGetCUIntArraySize $QUIntArrayPartsFromAllVariants]"
    set int [ $CVariantGroupsContainer GetAllParts $QUIntArrayPartsFromAllVariants]
    # puts "[CISTclHelper_sGetCUIntArraySize $QUIntArrayPartsFromAllVariants]"
    set QuitArraySize [CISTclHelper_sGetCUIntArraySize $QUIntArrayPartsFromAllVariants]
    set partProps [CISTclHelper_sMakeCPartProp]
    set propName [DboTclHelper_sMakeCString]
    set propValue [DboTclHelper_sMakeCString]
    # puts $QuitArraySize
    for {set z 0} {$z < $QuitArraySize} {incr z} {

    # set QUIntArrayUpperBound [QUIntArray_GetUpperBound $QUIntArrayPartsFromAllVariants]
    set partIntId [CISTclHelper_sGetUInt $QUIntArrayPartsFromAllVariants $z]
    if {$partIntId != 0} {
    set lUINTPartId [CISTclHelper_sGetUINTFromInt $partIntId]
    # puts $lUINTPartId
    set lCISInstOcc [$CISDesign GetPartOccForID $lUINTPartId]
    # puts $lCISInstOcc
    if {$lCISInstOcc != "NULL"} {

    set allPartProps [$lCISInstOcc GetPartProps $partProps]
    # set allPartPropsValue [$lCISInstOcc GetPropContents $partProps]
    set partPropName [$partProps GetPropNames]
    set CStringArraySize [CISTclHelper_sGetCStringArraySize $partPropName]

    #Get all the variant prop and it value for an lCISInstOcc

    # for {set x 0} {$x < $CStringArraySize} {incr x} {
    # set propCStringName [CISTclHelper_sGetCString $partPropName $x]
    # set propCstringValue [$partProps GetPropContents $propCStringName]
    # set propName [DboTclHelper_sGetConstCharPtr $propCStringName]
    # set propValue [DboTclHelper_sGetConstCharPtr $propCstringValue]
    # lappend propValueList $propValue
    # puts "$propName:= $propValue"

    # }

    set lRefDes [DboTclHelper_sMakeCString ]
    set lRefDes [$lCISInstOcc GetPartRefDes]
    set lRefDes [$lRefDes GetRefDes]
    # puts $lRefDes
    set lRefDesStr [DboTclHelper_sGetConstCharPtr $lRefDes]
    # puts $fp "$lRefDesStr"
    # puts "$lRefDesStr"
    lappend refdesList $lRefDesStr
    }
    }

    }

    # puts $refdesList

    for {set x 0} {$x<[llength $refdesList]} {incr x} {

    set lsearchRefDes [lsearch $newvalueList [lindex $refdesList $x]]
    if { $lsearchRefDes < 0} {

    lappend newvalueList [lindex $refdesList $x]
    # puts "[lindex $refdesList $x] is "


    } else {puts "[lindex $refdesList $x] is present morethan once"}


    }

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

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

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