3 Replies Latest reply on Jul 30, 2014 6:21 AM by Yong Ning

    How to hide Feature with API?

    Yong Ning

      0.jpg

       

      Private Sub ll()

        Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

        Dim SwDraw As DrawingDoc, SwSelMgr As SelectionMgr

        Dim SwFeat As Feature, BomFeat As BomFeature

          Set SwApp = Application.SldWorks

          Set SwModel = SwApp.ActiveDoc

          Debug.Print SwModel.GetTitle

          Set SwSelMgr = SwModel.SelectionManager

          ''

          Set BomFeat = SwSelMgr.GetSelectedObject6(1, -1)

          Set SwFeat = BomFeat.GetFeature

          Debug.Print SwFeat.Name

      End Sub

        • Re: How to hide Feature?
          Andrew Kronquist

          Yong,

          Right click on the Bill of Materials, click "Hide table"

           

          Hide.png

          • Re: How to hide Feature with API?
            Santosh Pawar

            Get the annotation object from the BomFeature and use Visible property to hide the BOM Table

             

            Dim swApp As Object

            Dim Part As Object
            Dim boolstatus As Boolean
            Dim longstatus As Long, longwarnings As Long
            Dim swFeat As SldWorks.Feature
            Dim swBomFeat As SldWorks.BomFeature
            Dim tAnnotation As SldWorks.TableAnnotation
            Dim swAnnotation As SldWorks.Annotation
            Dim swBOMAnnotation As SldWorks.BomTableAnnotation
            Dim SwSelMgr As SldWorks.SelectionMgr
            Sub main()

            Set swApp = _
            Application.SldWorks

            Set Part = swApp.ActiveDoc
            boolstatus = Part.Extension.SelectByID2("Bill of Materials1", "BOMFEATURE", 0, 0, 0, False, 0, Nothing, 0)
            Set SwSelMgr = Part.SelectionManager
            Set swBomFeat = SwSelMgr.GetSelectedObject6(1, -1)
            Set tAnnotation = swBomFeat.GetTableAnnotations(0)
            Set swAnnotation = tAnnotation.GetAnnotation
            swAnnotation.Visible = swAnnotationVisibilityState_e.swAnnotationHidden
            End Sub

              • Re: How to hide Feature with API?
                Yong Ning

                Thanks your tips

                 

                follow code is

                 

                Private Sub ll()

                  Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                  Dim SwDraw As DrawingDoc, SwSelMgr As SelectionMgr

                  Dim SwFeat As Feature, BomFeat As BomFeature

                    Set SwApp = Application.SldWorks

                    Set SwModel = SwApp.ActiveDoc

                    Debug.Print SwModel.GetTitle

                    Set SwSelMgr = SwModel.SelectionManager

                    ''

                    Set BomFeat = SwSelMgr.GetSelectedObject6(1, -1)

                  Dim SwTabAnn As TableAnnotation, SwAnn As Annotation

                    Set SwTabAnn = BomFeat.GetTableAnnotations(0)

                    Set SwAnn = SwTabAnn.GetAnnotation

                    SwAnn.Visible = 3 'swAnnotationVisibilityState_e.swAnnotationHidden  

                End Sub

                 

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

                 

                Private Sub del0730()

                  Dim SwModel As ModelDoc2

                     Set SwModel = Application.SldWorks.ActiveDoc

                  Dim SwFeatMgr As SldWorks.FeatureManager, SwBomFeat As BomFeature, SwFeat As Feature

                 

                     Set SwFeatMgr = SwModel.FeatureManager

                     Set SwFeat = SwModel.FeatureByName("卧式贮罐主视图材料明细表")

                     Debug.Print SwFeat.Name

                     Set SwBomFeat = SwFeat.GetSpecificFeature

                     Debug.Print SwBomFeat.GetFeature.Name

                  Dim SwTabAnn As TableAnnotation, SwAnn As Annotation

                    Set SwTabAnn = SwBomFeat.GetTableAnnotations(0)

                    Set SwAnn = SwTabAnn.GetAnnotation

                    'SwAnn.Visible = 1 'swAnnotationVisibilityState_e.swAnnotationHidden

                     SwAnn.Visible = swAnnotationVisibilityState_e.swAnnotationHalfHidden

                     Stop

                     SwAnn.Visible = swAnnotationVisibilityState_e.swAnnotationHidden

                     Stop

                     SwAnn.Visible = swAnnotationVisibilityState_e.swAnnotationVisible

                     Stop

                End Sub