MLeaderStyle Example

Using Programming Languages other than VBA

Sub MLS()

	Dim oDict As AcadDictionary
	Set oDict = ThisDrawing.Dictionaries.Item("ACAD_MLEADERSTYLE")

	Dim i As Long
	For i = 0 To oDict.Count - 1
	Dim oObj As AcadObject
	Set oObj = oDict.Item(i)
	If oObj.ObjectName = "AcDbMLeaderStyle" Then
		Dim oMLS As AcadMLeaderStyle
		Set oMLS = oObj
		MsgBox "Name = " & oMLS.Name & vbCrLf & _
		"Annotative = " & oMLS.Annotative & vbCrLf & _
		"ContentType = " & oMLS.ContentType & vbCrLf & _
		"LeaderLineType = " & oMLS.LeaderLineType, vbInformation, "MLeader Styles"
	End If
	Next i
	Dim oNewMLS As AcadMLeaderStyle
	Set oNewMLS = oDict.AddObject("TEST", "AcDbMLeaderStyle")

	oNewMLS.LeaderLineType = acSplineLeader
	Dim oCol As New AcadAcCmColor
	oCol.ColorIndex = acBlue
	oNewMLS.LeaderLineColor = oCol

	Call ThisDrawing.SetVariable("CMLEADERSTYLE", "TEST")
	Dim points(0 To 5) As Double
	points(0) = 1: points(1) = 1: points(2) = 0
	points(3) = 2: points(4) = 2: points(5) = 0
	Dim oML As AcadMLeader
	Set oML = ThisDrawing.ModelSpace.AddMLeader(points, i)
	oML.TextString = "mleader created with " & vbCrLf & "style ""TEST"""

End Sub

 

   Comments?