Get View Bounding Box and Position Example (VBA)
This example shows how to get the drawing view's bounding box and its
position.
'-------------------------------------
Option Explicit
Sub main()
Dim
swApp As
SldWorks.SldWorks
Dim
swModel As
SldWorks.ModelDoc2
Dim
swDraw As
SldWorks.DrawingDoc
Dim
swView As
SldWorks.view
Dim
vOutline As
Variant
Dim
vPos As
Variant
Dim
bRet As
Boolean
Set
swApp = CreateObject("SldWorks.Application")
Set
swModel = swApp.ActiveDoc
Set
swDraw = swModel
Set
swView = swDraw.GetFirstView
Do
While Not swView Is Nothing
vOutline
= swView.GetOutline
vPos
= swView.position
Debug.Print
"View = " + swView.Name
Debug.Print
" Pos
= (" & vPos(0) * 1000# & ", " & vPos(1) * 1000#
& ") mm"
Debug.Print
" Min
= (" & vOutline(0) * 1000# & ", " & vOutline(1)
* 1000# & ") mm"
Debug.Print
" Max
= (" & vOutline(2) * 1000# & ", " & vOutline(3)
* 1000# & ") mm"
Set
swView = swView.GetNextView
Loop
End Sub
'-------------------------------------