1 Reply Latest reply on Jul 5, 2018 11:12 AM by Fifi Riri

    Select origin shortcut

    Ask Corell

      Hi,

      I often find myself fiddling around to select the origin when dimensioning sketches, does anyone know of a macro that selects the origin while I'm in the smart dimension?

      I know that I can select the origin prior to starting smart dimension but that's still a bit awkward.

       

      Br,

        • Re: Select origin shortcut
          Fifi Riri

          Hello,

          This macro will create a dimension between the user selection and the origin

          Preconditions:

          - a sketch must be opened

          - an object (line, point, etc...) must be selected in the sketch

           

          Sub main()

              Dim swApp As Object

              Dim Part As Object

              Dim boolstatus As Boolean

              Set swApp = Application.SldWorks

              Set Part = swApp.ActiveDoc

              Dim swSelMgr As SldWorks.SelectionMgr

              Set swSelMgr = Part.SelectionManager

              Dim selObj As Object

              Set selObj = swSelMgr.GetSelectedObject6(1, 0)

              boolstatus = Part.Extension.SelectByID2("Point1@Origin", "EXTSKETCHPOINT", 0, 0, 0, True, 0, Nothing, 0)

              ' If you don't want to create the dimension automatically, remove the lines below

              Dim UserPreference As Boolean

              UserPreference = swApp.GetUserPreferenceToggle(swUserPreferenceToggle_e.swInputDimValOnCreate)

              swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swInputDimValOnCreate, False

              Dim myDisplayDim As Object

              Set myDisplayDim = Part.AddDimension2(0, 0, 0)

              swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swInputDimValOnCreate, UserPreference

          End Sub