Hello! I need to write a macro that changes the text on the leader line of the weld symbol.
The HELP API has an example "Insert Weld Symbol" http://help.solidworks.com/2019/english/api/sldworksapi/insert_weld_symbol_example_vb.htm
Below is the macro text I wrote. It searches for a weld symbol in the model and sets the new text on the leader line as
it was done in the example from the Help API. Unfortunately, the text on the leader line does not change.
I would be grateful for any help.
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 vSheetNames As Variant
Dim vSheetName As Variant
Dim vAnns As Variant
Dim vAnn As Variant
Dim swWeldSymbol As SldWorks.WeldSymbol
Dim i As Long, i1 As Long
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
vSheetNames = swDraw.GetSheetNames
For Each vSheetName In vSheetNames
swDraw.ActivateSheet vSheetName
'swModel.ViewZoomtofit2
Set swView = swDraw.GetFirstView
While Not swView Is Nothing
'Debug.Print swView.Name
'Debug.Print swView.GetWeldSymbolCount()
vAnns = swView.GetWeldSymbols
If Not IsEmpty(vAnns) Then
For Each vAnn In vAnns
Set swWeldSymbol = vAnn
'Debug.Print swWeldSymbol.GetTextCount()
For i1 = 0 To swWeldSymbol.GetTextCount() - 1
'Debug.Print swWeldSymbol.GetTextAtIndex(i1)
Next
swWeldSymbol.SetText True, "Left", "BUTT", "Right", "Stagger", swWeldContourNone
Next
End If
Set swView = swView.GetNextView
Wend
Next
swDraw.ForceRebuild3 False
End Sub