Get Names of Components and Model's Handle and DIBSECTION Example (VBA)
This example shows how to get the names of the assembly components in
an open, but not active, assembly document. It also shows how to get the
window's handle and DIBSECTION of this model document.
'-------------------------------------
'
' Preconditions: Assembly document is open but not active.
'
' Postconditions: None
'
'---------------------------------
Option Explicit
Sub main()
Dim
swApp As
SldWorks.SldWorks
Dim
swModel As
SldWorks.ModelDoc2
Dim
swModView As
SldWorks.ModelView
Set
swApp = Application.SldWorks
Set
swModel = swApp.GetFirstDocument
Do
While Not swModel Is Nothing
'
Assembly components are open, but they are not visible
'
until opened by the user
Debug.Print
swModel.GetPathName & "
["
& swModel.Visible & "]"
Debug.Print
" "
& swModel.GetTitle
Set
swModView = swModel.ActiveView
Do
While Not swModView Is Nothing
Debug.Print
" hWnd
=
" & swModView.GetViewHWnd
Debug.Print
" DIB
=
" & swModView.GetViewDIB
Set
swModView = swModView.GetNext
Loop
Set
swModel = swModel.GetNext
Loop
End Sub
'-------------------------------------