Hi Andreas, I am guessing that item in the menu is "Rotate about Scene Floor". I am no API expert but in the help it seems there is a control for it on this page- scroll down or search for "Rotate About Scene Floor"
you are right, the menu item is "Rotate about Scene Floor", thanks for that.
I was able to figure out how to toggle this item with VBA:
EDIT: You have to set a reference to this library first:
SOLIDWORKS 2017 Commands type library
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim CommandID As Variant
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swModelDocExt = swModel.Extension
CommandID = swCommands_e.swCommands_View_Rotate_About_Vertical
Debug.Print "Command available " & swApp.IsCommandEnabled(CommandID)
'Toggle "Rotate about Scene Floor"
Debug.Print "Command success " & swModelDocExt.RunCommand(CommandID, "")
A step into the right direction, but one step is missing: How can I determine if the item is enabled or not?
I've searched the web and found this:
But it seems that the SWScene object doesn't support this feature... anyone any idea?
I have run into situations like this, where there is no API method to read the setting. Instead, you can read the registry. Look for the setting HKEY_CURRENT_USER\Software\Solidworks\SOLIDWORKS 2017\General\View Rotate About Vertical
The problem with this method is that the value is not written to the registry until SolidWorks is closed. So the value is not guaranteed to be accurate if the user has changed it during the current SolidWorks session.
Well, not perfect, but I think I can live with that.
For followers, below is a VBA function to read the value for the installed (highest) version.
Thanks and regards, Andreas.
Function IsRotateAboutSceneFloor() As Variant
Dim fso As Object 'Scripting.FileSystemObject
Dim wsh As Object 'IWshRuntimeLibrary.WshShell
Dim Installer As Object
Dim HighVersion As Long
Dim ProductCode As Variant, Version As Variant
Dim InstallLocation, ProductName
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set wsh = CreateObject("WScript.Shell")
Set Installer = CreateObject("WindowsInstaller.Installer")
For Each ProductCode In Installer.Products
InstallLocation = Installer.ProductInfo(ProductCode, "InstallLocation")
If InstallLocation <> "" Then
InstallLocation = InstallLocation & "SLDWORKS.exe"
If fso.FileExists(InstallLocation) Then
ProductName = UCase(Installer.ProductInfo(ProductCode, "ProductName"))
If ProductName Like "SOLIDWORKS #### *" Then
Version = Split(ProductName, " ")
If CDbl(Version(1)) > HighVersion Then HighVersion = CDbl(Version(1))
IsRotateAboutSceneFloor = _
wsh.RegRead("HKEY_CURRENT_USER\Software\Solidworks\SOLIDWORKS " & _
HighVersion & "\General\View Rotate About Vertical") <> 0