MACRO LIBRARY

Get the position of a view

Free public access. No account or subscription required.

Files

Get the position of a view

Code

'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
'Preconditions: Have drawing view selected.
'Postconditions: Immediate window displays X-Y location of drawing view.
    
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swView As SldWorks.View
    
Dim vPos As Variant
    
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    If Not swModel Is Nothing Then
        Set swSelMgr = swModel.SelectionManager
        
        If swSelMgr.GetSelectedObjectType3(1, -1) <> swSelDRAWINGVIEWS Then
            MsgBox "Please select a drawing view."
            End
        Else
            Set swView = swSelMgr.GetSelectedObject6(1, -1)
            vPos = swView.Position
            Debug.Print Round(vPos(0), 8)
            Debug.Print Round(vPos(1), 8)
        End If
    End If
End Sub
    
'Notes IView::Position is based off of the origin in the part.