Leader Associativity

Leaders are associated with their annotation so that when the annotation moves, the endpoint of the leader moves with it. As you move text and feature control frame annotation, the final leader line segment alternates between attaching to the left side and to the right side of the annotation according to the relation of the annotation to the penultimate (second to last) point of the leader. If the midpoint of the annotation is to the right of the penultimate leader point, then the leader attaches to the right; otherwise, it attaches to the left.

Removing either object from the drawing using either the Erase, Add (to add a block), or WBlock method will break associativity. If the leader and its annotation are copied together in a single operation, the new copy is associative. If they are copied separately, they will not be associative. If associativity is broken for any reason, for example, by copying only the Leader object or by erasing the annotation, the hook line will be removed from the leader.

Associate a leader to the annotation

This example creates an MText object. A leader line is then created using the MText object as its annotation.

Sub Ch5_AddAnnotation()
	Dim leaderObj As AcadLeader
	Dim mtextObj As AcadMText
	Dim points(0 To 8) As Double
	Dim insertionPoint(0 To 2) As Double
	Dim width As Double
	Dim leaderType As Integer
	Dim annotationObject As Object
	Dim textString As String, msg As String

	' Create the MText object in model space
	textString = "Hello, World."
	insertionPoint(0) = 5
	insertionPoint(1) = 5
	insertionPoint(2) = 0
	width = 2
	Set mtextObj = ThisDrawing.ModelSpace. _
			 AddMText(insertionPoint, width, textString)

	' Data for Leader
	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

	' Create the Leader object in model space and associate
	' the MText object with the leader
	Set annotationObject = mtextObj
	Set leaderObj = ThisDrawing.ModelSpace. _
			AddLeader(points, annotationObject, leaderType)
End Sub