aamoroso
Mechanical
- Mar 5, 2003
- 432
I am working on this macro to format all text on a drawing. Currently (as it is below) it gets all notes on sheet that are not in a view, and gets all notes on all sheets not in a view. I need to get the text from views also, does anyone know what I am missing. Reason I am trying this it to get our font type consistant in older drawings for a viewer we use on the macintosh systems here to view our dxf files. Our doc control suggests we change all drawings to Helvetica font. Easy enough for future work and for notes using Doc Settings but many are not covered.
Sub main()
Set swApp = Application.SldWorks
Set Document = swApp.ActiveDoc
If Not Document Is Nothing Then
FileTyp = Document.GetType
If FileTyp = swDocDRAWING Then
SheetNames = Document.GetSheetNames
For i = 0 To Document.GetSheetCount - 1
Document.ActivateSheet (SheetNames(i))
Set View = Document.GetFirstView
Debug.Print "View = " + View.Name
Set Annotation = View.GetFirstAnnotation2
While Not Annotation Is Nothing
If Annotation.GetType >= 1 Then
Set note = Annotation.GetSpecificAnnotation
noteval = note.GetText
textpoint = note.GetTextPoint
Debug.Print noteval
Set swAnn = Annotation
For j = 0 To swAnn.GetTextFormatCount - 1
Set swTextFormat = swAnn.GetTextFormat(j)
swTextFormat.Bold = True
swTextFormat.Italic = True
swTextFormat.TypeFaceName = "Helvetica"
bRet = swAnn.SetTextFormat(i, False, swTextFormat): Debug.Assert bRet
Next
Set Annotation = Annotation.GetNext2
End If
Wend
Next i
If i > 0 Then
Document.ActivateSheet (SheetNames(0))
End If
End If
Document.EditSheet
Document.ForceRebuild
Else
MsgBox "Current document is not a drawing."
End If
End Sub
Sub main()
Set swApp = Application.SldWorks
Set Document = swApp.ActiveDoc
If Not Document Is Nothing Then
FileTyp = Document.GetType
If FileTyp = swDocDRAWING Then
SheetNames = Document.GetSheetNames
For i = 0 To Document.GetSheetCount - 1
Document.ActivateSheet (SheetNames(i))
Set View = Document.GetFirstView
Debug.Print "View = " + View.Name
Set Annotation = View.GetFirstAnnotation2
While Not Annotation Is Nothing
If Annotation.GetType >= 1 Then
Set note = Annotation.GetSpecificAnnotation
noteval = note.GetText
textpoint = note.GetTextPoint
Debug.Print noteval
Set swAnn = Annotation
For j = 0 To swAnn.GetTextFormatCount - 1
Set swTextFormat = swAnn.GetTextFormat(j)
swTextFormat.Bold = True
swTextFormat.Italic = True
swTextFormat.TypeFaceName = "Helvetica"
bRet = swAnn.SetTextFormat(i, False, swTextFormat): Debug.Assert bRet
Next
Set Annotation = Annotation.GetNext2
End If
Wend
Next i
If i > 0 Then
Document.ActivateSheet (SheetNames(0))
End If
End If
Document.EditSheet
Document.ForceRebuild
Else
MsgBox "Current document is not a drawing."
End If
End Sub