2 Replies Latest reply on Feb 15, 2013 6:36 PM by Tom Cote

    Get Sheet scale for multiple sheet drawings

    Tom Cote

      Hi guys,


      I'm trying to get the scale of each sheet of a drawing as I loop through them.


      Basically the code from the API help (shown below) will get the scale of the current sheet.  I am doing some tasks to each sheet by using a loop command:


      For i =0 to sheet count -1 and the NEXT command at the end.


      Everything seens to work fine except that the scale does not update per sheet and uses the scale for the sheet that was active when I started the macro.  So if sheet 2 was active and the scale of that sheet is 1:2 but the other sheets 1 & 3 have a sheet scale of 1:1 then it will stay at 1:2 becasue that was active when I started the macro.


      Anybody have any ideas?


      Thanks in advance.




      ' Postconditions: Drawing scale set to decimal.



      Option Explicit

      Sub main()

          Dim swApp                       As SldWorks.SldWorks

          Dim swModel                     As SldWorks.ModelDoc2

          Dim swDraw                      As SldWorks.DrawingDoc

          Dim swSelMgr                    As SldWorks.SelectionMgr

          Dim swView                      As SldWorks.View

          Dim vScaleRatio                 As Variant

          Dim bRet                        As Boolean

          Set swApp = Application.SldWorks

          Set swModel = swApp.ActiveDoc

          Set swDraw = swModel

          Set swSelMgr = swModel.SelectionManager

          Set swView = swSelMgr.GetSelectedObject5(1)


          vScaleRatio = swView.ScaleRatio


          Debug.Print "File = " & swModel.GetPathName

          Debug.Print "  View = " & swView.Name

          Debug.Print "    UseSheetScale  = " & CBool(swView.UseSheetScale)

          Debug.Print "    Scale          = " & vScaleRatio(0) & ":" & vScaleRatio(1)

          Debug.Print "                   = " & swView.ScaleDecimal


          ' Changing scale sets View::UseSheetScale to FALSE

          swView.ScaleDecimal = swView.ScaleDecimal * 2#


          ' Rebuild to see new scale

          bRet = swModel.EditRebuild3: Debug.Assert bRet

      End Sub