Solidworks二次开发—12—工程图的note
Solidworks二次开发—12—工程图的note 下面的程序读取当前图纸的每一个note,并在debug中打印结果。
Option Explicit
Dim swname As String
Dim swtext As String
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swNote As SldWorks.note
Dim swAnn As SldWorks.Annotation
Dim bRet As Boolean
Debug.Print 'begin:' & Chr(10)
Set swApp = CreateObject('SldWorks.Application')
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set swView = swDraw.GetFirstView ' This is the drawing template.i don't need to care about it
Set swNote = swView.GetFirstNote
swModel.ClearSelection2 (True)
Debug.Print 'File = ' & swModel.GetPathName
Do While Not swNote Is Nothing
Set swAnn = swNote.GetAnnotation
bRet = swAnn.Select2(True, 0)
Debug.Assert bRet
swname = swNote.GetName
swtext = swNote.GetText
Debug.Print ' 名称:' & swNote.GetName; ' *** 文本: ' & swNote.GetText
Set swNote = swNote.GetNext
Loop
End Sub