Creates a leader line based on the provided coordinates or adds a new leader cluster to the MLeader object.
Supported platforms: Windows only
VBA:
RetVal = object.AddLeader(PointsArray, Annotation, Type)
Type: Block, ModelSpace, PaperSpace
The objects this method applies to.
Access: Input-only
Type: Variant (array of doubles)
The array of 3D WCS coordinates specifying the leader. You must provide at least two points to define the leader. The third point is optional.
Access: Input-only
Type: BlockReference, MText, Tolerance
The object that should be attached to the leader. The value can also be NULL to not attach an object.
Access: Input-only
Type: AcLeaderType enum
VBA:
RetVal = object.AddLeader
Type: MLeader
The object this method applies to.
Type: Long
The index of the added leader cluster
Block, ModelSpace, PaperSpace: The leader is a line that connects some annotation to a feature in a drawing. Leaders and their annotation are associative, which means if you modify the annotation, the leader updates accordingly. The annotation can be a Tolerance, MText, or BlockReference object.
You can also create leaders that are not associated to a particular object. To do this, simply input a NULL object as the annotation.
VBA:
Sub Example_AddLeader()
    ' This example creates a leader in model space.
    ' The leader is not attached to any annotation object
    ' in this example.
   
    Dim leaderObj As AcadLeader
    Dim points(0 To 8) As Double
    Dim leaderType As Integer
    Dim annotationObject As AcadObject
    
    points(0) = 0: points(1) = 0: points(2) = 0
    points(3) = 4: points(4) = 4: points(5) = 0
    points(6) = 4: points(7) = 5: points(8) = 0
    leaderType = acLineWithArrow
    Set annotationObject = Nothing
        
    ' Create the leader object in model space
    Set leaderObj = ThisDrawing.ModelSpace.AddLeader(points, annotationObject, leaderType)
    ZoomAll
    
End Sub
Sub Example_MLeaderLine()
    Dim oML As AcadMLeader
    Dim points(0 To 5) As Double
    points(0) = 1: points(1) = 1: points(2) = 0
    points(3) = 4: points(4) = 4: points(5) = 0
    Dim i As Long
    Set oML = ThisDrawing.ModelSpace.AddMLeader(points, i)
    Dim r As Long
    r = oML.AddLeader()
    points(4) = 10
    Call oML.AddLeaderLine(r, points)
    MsgBox "LeaderCount = " & oML.LeaderCount
    ZoomExtents
End Sub
Visual LISP:
(vl-load-com)
(defun c:Example_AddLeader()
    ;; This example creates a leader in model space.
    ;; The leader is not attached to any annotation object
    ;; in this example.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    (setq modelSpace (vla-get-ModelSpace doc))
  
    (setq points (vlax-make-safearray vlax-vbDouble '(0 . 8)))
    (vlax-safearray-fill points '(0 0 0
                                  4 4 0
                                  4 5 0
                                 )
    )
    (setq leaderType acLineWithArrow)
  
    ;; Create a temporary annotaion object
    (setq point (vlax-3d-point 4 5 0))
    (setq annotationObject (vla-AddMText modelSpace point 1 ""))  
    ;; Create the leader object in model space
    (setq leaderObj (vla-AddLeader modelSpace points annotationObject leaderType))
    ;; Remove the temporary annotaion object and adjust the last coordinate of the leader
    (vla-Erase annotationObject)
    (vla-put-Coordinate leaderObj 2 (vlax-3D-point 4 5 0))
    (vla-ZoomAll acadObj)
)
(defun c:Example_MLeaderLine()
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    (setq points (vlax-make-safearray vlax-vbDouble '(0 . 5)))
    (vlax-safearray-fill points '(1 1 0
                                  4 4 0
                                 )
    )  
    (setq i 0)
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq oML (vla-AddMLeader modelSpace points i))
    (setq r (vla-AddLeader oML))
    (vlax-safearray-put-element points 4 10)
    (vla-AddLeaderLine oML r points)
    (alert (strcat "LeaderCount = " (itoa (vla-get-LeaderCount oML))))
    (vla-ZoomExtents acadObj)
)