VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Reply
Message 1 of 2
BrentBurgess1980
285 Views, 1 Reply

MLeaders

Hi All,

I have some code that creates MLeaders, and it works great. My problem is opening the drawing after I have added the MLeaders, it throws a message box saying the drawing found errors. I continue the open and do an Audit, and my previously added MLeaderStyle gets deleted

AcDbDictionary(1F81) 500m ePermanentlyErased Delete Entry

I am unsure why it is doing this as when I run the code, it stores it in the dictionary.

Am I missing a step out somewhere?


Sub KBR_MLeaders()

StrMLeaderStyle = "500m"

Dim BlnMLSExists As Boolean
BlnMLSExists = False
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
If oMLS.Name = StrMLeaderStyle Then
BlnMLSExists = True
End If

End If
Next i

If BlnMLSExists = False Then
Dim oNewMLS As AcadMLeaderStyle
Set oNewMLS = oDict.AddObject(StrMLeaderStyle, "AcDbMLeaderStyle")

oNewMLS.LeaderLineType = acStraightLeader
oNewMLS.ArrowSize = 2.5
oNewMLS.ContentType = acMTextContent
oNewMLS.EnableLanding = True
oNewMLS.LeaderLineTypeId = "Continuous"
oNewMLS.LandingGap = 1.5
oNewMLS.DoglegLength = 5
oNewMLS.LeaderLineColor = acRed
oNewMLS.MaxLeaderSegmentsPoints = 2
oNewMLS.ScaleFactor = 500
oNewMLS.TextHeight = 3.5
oNewMLS.TextColor = acYellow
oNewMLS.TextLeftAttachmentType = acAttachmentMiddleOfTop
oNewMLS.TextRightAttachmentType = acAttachmentMiddleOfTop
oNewMLS.TextAlignmentType = acLeftAlignment
oNewMLS.TextStyle = ISOCP
End If

Call ThisDrawing.SetVariable("CMLEADERSTYLE", StrMLeaderStyle)

ThisDrawing.SendCommand "Mleader" & vbCr

End Sub


Thanks in advance

Brent
1 REPLY 1
Message 2 of 2

Brent,

I'm shooting in the dark on this one, but maybe you need to perform an update to the dictionary, style and possibly the drawing?

Sorry if that's no help...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost