SOLIDWORKS Macro to toggle “Auto-rotate view normal to sketch plane on sketch creation and sketch edit”

Article by Prasadh Annalingam, CSWE updated November 17, 2020

Article

The “Auto-rotate view normal to sketch plane on sketch creation and sketch edit” option, as it sounds, automatically rotates the view orientation to be normal to a sketch plane when it is created or edited. In this article I’ll show you how assign this option to a toggle switch.

The option is found in Tools > Options > System Options > Sketch > Auto-rotate view normal to sketch plane on sketch creation and sketch edit. This option is disabled (unchecked) by default in SOLIDWORKS 2020 and earlier but is enabled (checked) by default in SOLIDWORKS 2021.

SOLIDWORKS Auto-rotate view normal to sketch plane on sketch creation and sketch edit

Auto-rotate view normal to sketch plane on sketch creation and sketch edit

Every user is different; some prefer this option enabled all the time while others do not. If you are like me, you might prefer to toggle this option on and off to your liking with a simple click of a button. Although a Command Button doesn’t exist for this system option, a quick Macro can be created to toggle the option ON and OFF at will. Simply copy & paste the code below into a new Macro and you’ll be on your way.

Option Explicit
' ******************************************************************************
' Created by Javelin Technologies. Please use this Macro at your own discretion.
' Javelin Technologies is not responsible for any undesired results. Always test before use!
' This code will toggle the option "Auto-rotate view normal to sketch plane on sketch creation and sketch edit"
' ******************************************************************************
Dim swApp As SldWorks.SldWorks
Dim boolstatus As Boolean

Sub main()
Set swApp = Application.SldWorks

'Check the current Option Setting
boolstatus = swApp.GetUserPreferenceToggle(swUserPreferenceToggle_e.swAutoNormalToSketchMode)

'Switch the setting
If boolstatus Then
    swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swAutoNormalToSketchMode, False
Else
    swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swAutoNormalToSketchMode, True
End If

End Sub

If you are new to Macros, please see the following blog article on how to create Macro Buttons in SOLIDWORKS.

NOTE: The API examples are provided as is and should be used as reference only. You may use it in your environment, change it, or distribute it, but Javelin is not responsible for any types of damages whatsoever (including without limitation, damages from the loss of use, data, profits, or business) arising out of the uses of this information, applications or services.

Learn more about SOLIDWORKS Macros/API

You can learn more about how to create these on SOLIDWORKS API Help as well as the training Javelin provides, SOLIDWORKS VB for Applications and SOLIDWORKS API training courses, which you can take live online, or in one of our Canadian classrooms. Check our schedule to learn more.

Related Links

Get Certified SOLIDWORKS Services from Javelin

Javelin Experts can help you to:

Posts related to 'SOLIDWORKS Macro to toggle “Auto-rotate view normal to sketch plane on sketch creation and sketch edit”'

Prasadh Annalingam, CSWE

Prasadh is a Certified SOLIDWORKS Expert and Technical Applications Analyst based in the Javelin Oakville head office.