AnsweredAssumed Answered

Set SwBomFeat = SwFeat.???

Question asked by Yong Ning on Jun 17, 2014
Latest reply on Jun 17, 2014 by Bryan Compton


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


      End If

      Set SwFeat = SwFeat.GetNextFeature


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


          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


SolidWorks Forums: How to select bomtable in Feature.


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