Sub replSwAnn()
Dim rr, Str
Dim SwDraw As DrawingDoc, swDrawExt As SldWorks.ModelDocExtension
Dim SwSelMgr As SldWorks.SelectionMgr ''
Dim swTable As SldWorks.TableAnnotation
Dim SwAnn As Annotation
Dim SwTextFormat As TextFormat
Set SwDraw = Application.SldWorks.ActiveDoc
Set swDrawExt = SwDraw.Extension
Set SwSelMgr = SwDraw.SelectionManager
' Select general table feature in FeatureManager design tree
Set swTable = SwSelMgr.GetSelectedObject6(1, 0)
With swTable
Set SwAnn = .GetAnnotation
End With
''
Set SwTextFormat = SwAnn.GetTextFormat(0)'' SwTextFormat Result is Nothing
With SwTextFormat
.WidthFactor = 0.9 '→ don't run WidthFactor
End With
End Sub
SolidworksApi macros
Select Note result is True
Sub tSwAnn()
Dim rr, Str
Dim SwDraw As DrawingDoc, swDrawExt As SldWorks.ModelDocExtension
Dim SwSelMgr As SldWorks.SelectionMgr
''
Dim swTable As SldWorks.TableAnnotation
Dim SwNote As Note
Dim SwAnn As Annotation
Dim SwTextFormat As TextFormat
''
Set SwDraw = Application.SldWorks.ActiveDoc
Set swDrawExt = SwDraw.Extension
Set SwSelMgr = SwDraw.SelectionManager
' Select general table feature in FeatureManager design tree
Set SwNote = SwSelMgr.GetSelectedObject6(1, 0)
Set SwAnn = SwNote.GetAnnotation
''
''
Set SwTextFormat = SwAnn.GetTextFormat(0)
Debug.Print SwAnn.GetTextFormatCount
Stop
With SwTextFormat
.WidthFactor = 0.9
End With
SwAnn.SetTextFormat 0, False, SwTextFormat
End Sub
code
Set SwTextFormat = SwAnn.GetTextFormat(0) → don't Nothing
Debug.Print SwAnn.GetTextFormatCount → result is 1