2 Replies Latest reply on Jul 10, 2014 9:33 PM by Yong Ning

    How to select configruation option with?

    Yong Ning

      1.gif

      Hope select configuration option in bom with API

        • Re: How to select configruation option with?
          Artem Taturevych

          IBomTableAnnotation::BomFeature->IBomFeature::SetConfigurations

            • Re: How to select configruation option with?
              Yong Ning

              Sub main()

                Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2, SwDraw As DrawingDoc

                  ''

                  Set SwApp = Application.SldWorks

                  Set SwModel = SwApp.ActiveDoc

                Dim SwSelMgr As SelectionMgr

                  Set SwSelMgr = SwModel.SelectionManager

                  SwModel.Extension.SelectByID2 "Bill of Materials2", "BOMFEATURE", 0, 0, 0, False, 0, Nothing, 0

                Dim SwBomFeat As BomFeature

                  Set SwBomFeat = SwSelMgr.GetSelectedObject5(1)

                Dim Visible, Names

                  Names = SwBomFeat.GetConfigurations(False, Visible)

                  'Stop

               

               

                  Names(2) = ""

                  Names(1) = ""

                  Names(3) = ""

               

               

                  SwBomFeat.SetConfigurations True, Visible, Names

              End Sub

              ************************************

              Sub main()

                Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2, SwDraw As DrawingDoc

                  ''

                  Set SwApp = Application.SldWorks

                  Set SwModel = SwApp.ActiveDoc

                  Set SwDraw = SwModel

                Dim confStr, SwView As View

                   Set SwView = SwDraw.GetFirstView

                   Set SwView = SwView.GetNextView

                   confStr = SwView.ReferencedConfiguration

                   Stop

               

                Dim SwSelMgr As SelectionMgr

               

                  Set SwSelMgr = SwModel.SelectionManager

                  SwModel.Extension.SelectByID2 "卧式贮罐材料明细表", "BOMFEATURE", 0, 0, 0, False, 0, Nothing, 0

                Dim SwBomFeat As BomFeature

                  Set SwBomFeat = SwSelMgr.GetSelectedObject5(1)

                Dim Visible, Names

               

                  Names = SwBomFeat.GetConfigurations(False, Visible)

                  For ii = 0 To UBound(Names)

                    If Names(ii) <> confStr Then

                      Names(ii) = ""

                    End If

                  Next ii

                  Stop 

                  SwBomFeat.SetConfigurations True, Visible, Names

              End Sub

               

              **********************************

               

              Private Sub ll0()

                Dim SwModel As ModelDoc2

                Set SwModel = Application.SldWorks.ActiveDoc

                CustInfoName SwModel

              End Sub

              ''

              Function CustInfoName(SwModel As ModelDoc2)

                Dim SwConfig As Configuration, ConfArr, ConfName, CustArr

                Dim Str, kk

                  kk = 2

                  ConfArr = SwModel.GetConfigurationNames

                  For ii = 0 To UBound(ConfArr)

                      Set SwConfig = SwModel.GetConfigurationByName(ConfArr(ii))

                      ConfName = SwConfig.Name

                      With SwModel

                         Str = Chr(34) & "SW-Mass@@" & ConfName & "@" & .GetTitle & Chr(34)

                         .AddCustomInfo3 ConfName, "质量", 30, "12"

                         .CustomInfo2(ConfName, "质量") = Str '"""" & Str & """"

                         Str = Chr(34) & "SW-Material@@" & ConfName & "@" & .GetTitle & Chr(34)

                        

                        

                         .AddCustomInfo3 ConfName, "材料", 30, "12"

                         If UCase(.GetTitle) Like "*SLDASM" Then

                           .CustomInfo2(ConfName, "材料") = "组合件"

                         Else

                           .CustomInfo2(ConfName, "材料") = Str '"""" & Str & """"

                         End If

                         CustArr = .GetCustomInfoNames2(ConfName)

                         .ShowConfiguration ConfName

                      End With

                  Next ii

              End Function

              ''