1 Reply Latest reply on Jun 17, 2014 10:58 AM by Bryan Compton

    Set SwBomFeat = SwFeat.???

    Yong Ning

      1.jpg

      Private Sub ll()

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

          Set SwApp = GetObject(, "SldWorks.Application")

          Set SwModel = SwApp.ActiveDoc

          Set SwDraw = SwModel

        Dim SwFeat As Feature, SwBomFeat As BomFeature

          Set SwFeat = SwModel.FirstFeature

          Do While Not SwFeat Is Nothing

            ''

            If SwFeat.GetTypeName = "BomFeat" Then

              Debug.Print SwFeat.Name, SwFeat.GetTypeName

              Set SwBomFeat = SwFeat.GetDefinition

              Stop

            End If

            Set SwFeat = SwFeat.GetNextFeature

          Loop

      End Sub

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

      Option Explicit

      Dim Dic As New Dictionary

       

       

      Function DicShowConf(SwComp As Component2)

         Dim SwModel As ModelDoc2, ConfStr

            ConfStr = SwComp.ReferencedConfiguration

            Set SwModel = SwComp.GetModelDoc

       

             If Not Dic.Exists(SwModel.GetTitle) Then

                If Not SwModel Is Nothing Then

                   Dic(SwModel.GetTitle) = ""

                   SwModel.ShowConfiguration ConfStr

                   Debug.Print SwModel.GetTitle, ConfStr

                End If

             End If

      End Function

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

      Private Sub ShowConfigOfComponent()

        Dim oDic As New Dictionary, Str, ii, jj

       

        Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2, oSwModel As ModelDoc2

          Set SwApp = GetObject(, "SldWorks.Application")

          Set SwModel = SwApp.ActiveDoc

        Dim SwSelMgr As SelectionMgr

          Set SwSelMgr = SwModel.SelectionManager

        Dim SwAssy As AssemblyDoc, SwComp As Component2, oSwComp As Component2

          Set SwAssy = SwModel

        Dim SwConf As Configuration, SwRootComp As Component2

          Set SwConf = SwModel.GetActiveConfiguration

          Set SwRootComp = SwConf.GetRootComponent

        Dim ChildComp, oChildComp

          ChildComp = SwRootComp.GetChildren

          ''

          For ii = 0 To UBound(ChildComp)

             Set SwComp = ChildComp(ii)

             DicShowConf SwComp

             Set SwModel = SwComp.GetModelDoc

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

                oChildComp = SwComp.GetChildren

                Stop

                For jj = 0 To UBound(oChildComp)

                  Set oSwComp = oChildComp(jj)

                  DicShowConf oSwComp

                Next jj

             End If

          Next ii

      End Sub

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

      help me

      Set SwBomFeat = SwFeat.???

       

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

      SolidWorks Forums: How can I change the reference config. of a BOM in a draw

      https://forum.solidworks.com/message/146275#146275

       

      SolidWorks Forums: How to select bomtable in Feature.

      https://forum.solidworks.com/message/396038#396038

       

      SolidWorks Forums: Get Components in Each BOM Table Row Example (VB.NET)

      https://forum.solidworks.com/message/219723#219723