Get Centerlines in Drawing Example (VBA)
This example shows how to get all of the centerlines in all of the drawing
views in a drawing.
'------------------------------------
'
' Preconditions: Drawing is open and at least one view
' contains
a centerline annotation.
'
' Postconditions: None
'
'------------------------------------
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
swCenterLine As
SldWorks.CenterLine
Dim
swAnn As
SldWorks.Annotation
Dim
bRet As
Boolean
Set
swApp = CreateObject("SldWorks.Application")
Set
swModel = swApp.ActiveDoc
Set
swDraw = swModel
Set
swView = swDraw.GetFirstView
Debug.Print
"File = " & swModel.GetPathName
Do
While Not swView Is Nothing
Debug.Print
" View
= " + swView.GetName2
Set
swCenterLine = swView.GetFirstCenterLine
Do
While Not swCenterLine Is Nothing
Set
swAnn = swCenterLine.GetAnnotation
Debug.Print
" Name
=
" & swAnn.GetName
Set
swCenterLine = swCenterLine.GetNext
Loop
Set
swView = swView.GetNextView
Loop
End Sub