2 Replies Latest reply on Jul 26, 2018 1:10 PM by Eric Jacobson

    Check edge colour and change

    Eric Jacobson

      Hi, all!

       

      I'm trying to write a macro where I can hit a key, the macro will check my edge colour and, if black, change it to blue, and if blue, change it back to black.

       

      I'm obviously pretty new at this. Id appreciate some help pointing me in the right direction.

       

      This is what I have so far:

       

       

       

      Sub main()

      Set swApp = Application.SldWorks

      Set Part = swApp.ActiveDoc

       

       

       

       

      'Check if Blue

      While boolstatus = swApp.SetUserPreferenceIntegerValue(swUserPreferenceIntegerValue_e.swSystemColorsSurfacesOpenEdge, 16744448)

          boolstatus = swApp.SetUserPreferenceIntegerValue(swUserPreferenceIntegerValue_e.swSystemColorsSurfacesOpenEdge, 0)

          Wend

          'Now black, redirect

              GoTo line1

      'Check if black

      While boolstatus = swApp.SetUserPreferenceIntegerValue(swUserPreferenceIntegerValue_e.swSystemColorsSurfacesOpenEdge, 0)

          boolstatus = swApp.SetUserPreferenceIntegerValue(swUserPreferenceIntegerValue_e.swSystemColorsSurfacesOpenEdge, 16744448)

          Wend

         

      line1:

            boolstatus = Part.EditRebuild3()

      End Sub

        • Re: Check edge colour and change
          Fifi Riri

          Hello,try this

           

          Option Explicit

          Sub main()

          Dim swApp As SldWorks.SldWorks

          Set swApp = Application.SldWorks

          Dim boolstatus As Boolean

          If swApp.GetUserPreferenceIntegerValue(swUserPreferenceIntegerValue_e.swSystemColorsSurfacesOpenEdge) = 0 Then

          boolstatus = swApp.SetUserPreferenceIntegerValue(swUserPreferenceIntegerValue_e.swSystemColorsSurfacesOpenEdge, 16744448)

          Else

          boolstatus = swApp.SetUserPreferenceIntegerValue(swUserPreferenceIntegerValue_e.swSystemColorsSurfacesOpenEdge, 0)

          End If

          Dim Part As SldWorks.PartDoc

          Set Part = swApp.ActiveDoc

          boolstatus = Part.EditRebuild3

          End Sub