2 Replies Latest reply on Oct 13, 2017 12:31 AM by ozaouiidrissi

    export BOM Files from Variant Manager for each Board using VBS




      I need to export BOM Files from Variant Manager for each Board, i create the function below with VBS that export BOMs files for active Board


      Function BOMObjectGenerationFromVariantManager(OutputPathField, FormatField, IncludeMasterField, TypeField, PropertiesField, UserPropsField)


      BOMObjectGenerationFromVariantManager = False

      Dim vmBOM     

      Set vmBOM = VmappObj.BOM

      vmBOM.OutputPath = OutputPathField

      vmBOM.Format = FormatField

      vmBOM.IncludeMaster = IncludeMasterField

      vmBOM.Type = TypeField

      vmBOM.Properties = PropertiesField

      vmBOM.UserProps = UserPropsField

      Dim vmvar

      For Each vmvar In VmdocObj.Variants

      vmBOM.Add vmvar.Name



      BOMObjectGenerationFromVariantManager = True


      End Function


      i tried to implement a loop as : For BoardNum = 1 To siCDBNum but every time it export BOMs files for the active board


      Please can you help me to export BOM files for each board pragmatically ?


      Best Regards,


        • 1. Re: export BOM Files from Variant Manager for each Board using VBS

          Hi - assuming that your oApp is set correctly (as in Set oApp = GetObject(,Viewdraw.Application) or similar,

          You need to find the boards in the design (GetiCDBDesigns Method below)


          Dim i
          Set oProjData = Application.GetProjectData()
          Set objiCDBDesigns = oProjData.GetiCDBDesigns()
          If objiCDBDesigns.Getcount > 1 Then 'More than 1 board in project
            For i = 1 To objiCDBDesigns.Getcount
               MsgBox objiCDBDesigns.GetItem(i) ' this will list the Board Name
            Next 'i 
          End If ' objiCDBDesigns.Getcount

          End Sub 'Init


          Obviously, you want to do more than just listing the name, so

          For i = 1 to objiCDBDesigns.Getcount

               strBoardName = objiCDBDEsigns.GetItem(i)

               sTopLevelBlock = oProjData.GetiCDBDesignRootBlock(strBoardName)

               Call ExportVariants(sTopLevelBlock) 'this is the call to the routine that exports Variant Data

          Next 'i


          None of the above is debugged, so it may need some tinkering, but it should get you started.

          • 2. Re: export BOM Files from Variant Manager for each Board using VBS

            Hi Peter,

            Thank you, i found the solution, the loop below force a sheet to be active view, and it's executed just one time


            For BoardNum = 1 To siCDBNum

                 For SheeNum = 1 To sheetObj.GetCount

                      ActiView=dxdApp.SchematicSheetDocuments.Open (schmObj.GetItem(BoardNum), sheetObj.GetItem(SheeNum))


                      Call Function BOMObjectGenerationFromVariantManager(....)

                      Exit For