AnsweredAssumed Answered

Macro that replaces text on the leader line of the weld symbol

Question asked by Boris Sorin on Nov 6, 2019

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"
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
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)

swWeldSymbol.SetText True, "Left", "BUTT", "Right", "Stagger", swWeldContourNone

End If

Set swView = swView.GetNextView



swDraw.ForceRebuild3 False


End Sub