4 Replies Latest reply on Sep 12, 2017 1:44 AM by Andreas Killer

    RotateAboutAxis did (not) work in SW2017 SP4.1

    Andreas Killer

      Good things take time, 3 months before I've created this thread about nearly the same topic:



      Now I have SW2017 SP4.1 and at the first time I run my macro, I've found that I'm facing the same issue, RotateAboutAxis did not work.


      I have checked my graphics card, started the machine in safe mode, and did many other things, but the macro did not work.
      Then I accidentally right-clicked on the screen and found this item was checked:


      And after I unchecked my macro works! Hurray!


      I've searched the documentation, but I can not find a way to get/set this with Set-/GetUserPreferenceToggle.Or is there an other method for that?



        • Re: RotateAboutAxis did (not) work in SW2017 SP4.1
          Adam Hartles

          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"


          2017 SOLIDWORKS API Help - swCommands_e Enumeration


            • Re: RotateAboutAxis did (not) work in SW2017 SP4.1
              Andreas Killer

              Hi Adam,

              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
              {0AC1DE9F-3FBC-4C25-868D-7D4E9139CCE0} 25.0




              Sub Test()
                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, "")
              End Sub



              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?



                • Re: RotateAboutAxis did (not) work in SW2017 SP4.1
                  Andrew Johnson

                  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.

                    • Re: RotateAboutAxis did (not) work in SW2017 SP4.1
                      Andreas Killer

                      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))
                              End If
                            End If
                          End If
                        IsRotateAboutSceneFloor = _
                          wsh.RegRead("HKEY_CURRENT_USER\Software\Solidworks\SOLIDWORKS " & _
                          HighVersion & "\General\View Rotate About Vertical") <> 0
                      End Function