Get Scale of Each Model View (VBA)
This example shows how to get the scale of each model view in a model
document.
'---------------------------------
' Preconditions: Model document is open and
' has
at least one model view.
'
' Postconditions: None
'---------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim SwModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swModView As SldWorks.modelview
Dim swModViews As Variant
Dim index As Integer
Dim Count As Long
Sub main()
Set swApp = Application.SldWorks
Set SwModel = swApp.ActiveDoc
Set swModelDocExt = SwModel.Extension
' Get model views
swModViews = swModelDocExt.GetModelViews
' Get number of model views
Count = swModelDocExt.GetModelViewCount
Debug.Print "Number of model views: " &
Count
' Get scale of each model view
For index = LBound(swModViews) To UBound(swModViews)
Set swModView = swModViews(index)
Debug.Print "Scale of model view: "
& index & " is " & swModView.Scale2
Next index
End Sub