2 Replies Latest reply on Sep 18, 2013 5:00 AM by Yong Ning

    How to judge  Is Feature Suppressed ?

    Yong Ning

      01.jpg

       

      Sub ll()

        Dim SwModel As ModelDoc2, SwFeat As Feature

        Set SwModel = Application.SldWorks.ActiveDoc

        Set SwFeat = SwModel.FirstFeature

        Do While Not SwFeat Is Nothing

          Debug.Print SwFeat.Name, SwFeat.GetTypeName

      '***************

      How to  jedge select Feature 

      Featur Suppressed

           or

      Featire unSuppressed

       

      ''*****************

          Set SwFeat = SwFeat.GetNextFeature

        Loop

      End Sub

        • Re: How to judge  Is Feature Suppressed ?
          Artem Taturevych

          In your case this is the component but not feature (you can cast to feature). Here is the example:

           

          Dim swApp As SldWorks.SldWorks

          Dim swModel As SldWorks.ModelDoc2

          Dim swAssy As SldWorks.AssemblyDoc

          Dim swSelMgr As SldWorks.SelectionMgr

          Dim swComp As SldWorks.Component2

           

          Sub main()

           

              Set swApp = Application.SldWorks

           

              Set swModel = swApp.ActiveDoc

           

           

              Set swSelMgr = swModel.SelectionManager

           

           

              Set swAssy = swModel

           

              Set swComp = swSelMgr.GetSelectedObjectsComponent(1)

           

              If swComp.GetSuppression() = swComponentSuppressionState_e.swComponentResolved _

                  Or swComp.GetSuppression() = swComponentSuppressionState_e.swComponentFullyResolved Then

                  MsgBox "Not Suppressed"

              Else

                  MsgBox "Suppressed"

              End If

           

          End Sub

           

          ____________________________________________________

          Regards,

          Artem Taturevych, Application Engineer at Intercad (Australia)

           

          translationXpert – add-in to translate SolidWorks models

          myIntercad an integrated tool for SolidWorks Professionals

          LinkedIn SolidWorks API Education Group

            • Re: How to judge  Is Feature Suppressed ?
              Yong Ning

              Thank your code.

              your code is need code for me.

               

              0.jpg

               

              Private Sub fdsafdsafdsa()

                Dim swModel As ModelDoc2, swFeat As Feature, vModel As ModelDoc2

                Set swModel = Application.SldWorks.ActiveDoc

                Dim SwSelMgr As SelectionMgr, SwComp As Component2

                Dim SelArray(1 To 1)

                Set SwSelMgr = swModel.SelectionManager

                Set swFeat = swModel.FirstFeature

                Do While Not swFeat Is Nothing

                 

                  If swFeat.GetTypeName = "Reference" Then '

                    swFeat.Select False

                    'Set SwComp = SwSelMgr.GetSelectedObjectsComponent(1)

                   

                    If UCase(swFeat.name) Like "*VOLUME*" Then

                      Debug.Print swFeat.name & "  Need Suppressed"

                     

                      swModel.EditSuppress

                     

                    End If

                  End If

                  Set swFeat = swFeat.GetNextFeature

                Loop

              End Sub

               

               

               

              Sub TraverCompFeat()

                Dim swModel As ModelDoc2, swFeat As Feature

                Set swModel = Application.SldWorks.ActiveDoc

                Dim SwSelMgr As SelectionMgr, SwComp As Component2

                Dim SelArray(1 To 1)

                Set SwSelMgr = swModel.SelectionManager

                Set swFeat = swModel.FirstFeature

                Do While Not swFeat Is Nothing

                  '

                  If swFeat.GetTypeName = "Reference" Then '

                    swFeat.Select False

                    Set SwComp = SwSelMgr.GetSelectedObjectsComponent(1)

                    If SwComp.GetSuppression() < 2 Or SwComp.GetSuppression() > 3 Then

                      Debug.Print swFeat.name & " Suppressed"

                      SwComp.SetSuppression2 3

                    End If

                  End If

                  Set swFeat = swFeat.GetNextFeature

                Loop

              End Sub