Dear @AmenJlili @PeterBrinkhuis @artem @Gupta9665
I have been using below code from SolidWorks API documentation. In which I have added
swModel.ForceRebuild3 True . after force rebuild the leader point come to original position.
The below code for your review:
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDrawing As SldWorks.DrawingDoc
Dim swAnnot As SldWorks.Annotation
Dim vAnnotations As Variant
Dim swView As SldWorks.View
Dim i As Integer
Dim bRet As Boolean
Dim cnt As Long
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDrawing = swModel
Set swView = swDrawing.ActiveDrawingView
Debug.Assert Not swView Is Nothing
Debug.Print "Name of drawing view: " & swView.GetName2
vAnnotations = swView.GetAnnotations
For i = 0 To UBound(vAnnotations)
Set swAnnot = vAnnotations(i)
swAnnot.Select3 True, Nothing
cnt = swAnnot.GetLeaderCount
If cnt = 1 Then
bRet = swAnnot.SetLeaderAttachmentPointAtIndex(0, 0.687021207260901, 0.599975917260352, 250.03275)
If (bRet) Then
swModel.ForceRebuild3 True
Debug.Print "Leader attached successfully"
End If
End If
Next i
End Sub
Note: Please have a note with leader in the selected view.
SetLeaderAttachmentPointAtIndex API setting the position of leader point. But after force rebuild, The Complete Annotation position moves & Leader point Moves to its original position.
Please confirm its a bug or anything I was missing.
Reference Links (earlier Discussions):
Revision Table Balloon Moves After Rebuild - SOLIDWORKS / API/VBA Macros - cadoverflow