2 Replies Latest reply on Jun 16, 2014 8:29 AM by Klaudiusz Skiba

    Surface Finish Number with Macro

    Klaudiusz Skiba

      Hi, I have another question about surface finishes on solidworks drawings. I need to gather all surface finish numbers. I need help with aquiring one, the rest I can do on my own. Thank you a lot. Also posting a picture showing what I need:

      Untitledmacrp.png

        • Re: Surface Finish Number with Macro
          Artem Taturevych

          Here is the macro to get all surface finish symbols from active drawing view. Macro outputs Minimum Roughness value to the Immidiate VBA window:

           

          Dim swApp As SldWorks.SldWorks

          Dim swDraw As SldWorks.DrawingDoc

           

          Sub main()

           

              Set swApp = Application.SldWorks

             

              Set swDraw = swApp.ActiveDoc

             

              Dim vSheets As Variant

             

              vSheets = swDraw.GetViews

             

              Dim i As Integer

              Dim j As Integer

              Dim k As Integer

             

              For i = 0 To UBound(vSheets)

                 

                  Dim vViews As Variant

                  vViews = vSheets(i)

                 

                  For j = 0 To UBound(vViews)

                 

                      Dim swView As SldWorks.View

                      Set swView = vViews(i)

                     

                      Dim vSfSymbs As Variant

                      vSfSymbs = swView.GetSFSymbols

                     

                      If Not IsEmpty(vSfSymbs) Then

           

                          For k = 0 To UBound(vSfSymbs)

                              Dim swSfSymb As SldWorks.SFSymbol

                              Set swSfSymb = vSfSymbs(k)

                              Debug.Print swSfSymb.GetText(swSurfaceFinishSymbolText_e.swSFSymbolMinimumRoughness)

                          Next

           

                      End If

                     

                  Next

                 

              Next

             

          End Sub