2 Replies Latest reply on Feb 15, 2018 12:54 PM by Patrick Dunleavy

    Help with simple macros and keyboard shortcuts

    Patrick Dunleavy

      I've created two macros. One to turn drawing items red and another to turn them black. I've assigned them the keyboard shortcuts of R and B, respectively. They work fine on everthing when I run them from the macro toolbar. When I use the keyboard shortcuts, they work for notes, datums, part lines (sides), and geometric tolerances so far, but they do not work with dimensions. I created the macros by selecting a dimension, hitting record, changing its color, pressing ESC, and then stopping the recording. Any idea why it only works for dimensions when run from the toolbar and not with the shortcut? Thanks for any help or pointers.

       

      Both codes:

      Red:

       

      Dim swApp As Object

      Dim Part As Object
      Dim boolstatus As Boolean
      Dim longstatus As Long, longwarnings As Long

      --------------------------------------------------------------

      Sub main()

      Set swApp = _
      Application.SldWorks

      Set Part = swApp.ActiveDoc
      Part.SetLineColor 255
      Part.SetPickMode
      Part.ClearSelection2 True
      boolstatus = Part.ActivateSheet("Sheet1")
      End Sub

       

      Black:

       

      Dim swApp As Object

      Dim Part As Object
      Dim boolstatus As Boolean
      Dim longstatus As Long, longwarnings As Long

      --------------------------------------------------------------

      Sub main()

      Set swApp = _
      Application.SldWorks

      Set Part = swApp.ActiveDoc
      Part.SetLineColor 0
      Part.SetPickMode
      Part.ClearSelection2 True
      boolstatus = Part.ActivateSheet("Sheet1")
      End Sub