Visual Basic Customization

Reply
Mentor
BrentBurgess1980
Posts: 162
Registered: ‎06-16-2008
Message 1 of 2 (178 Views)

MLeaders

178 Views, 1 Replies
08-03-2009 06:25 PM
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
Distinguished Contributor
TCARPENTER_67
Posts: 104
Registered: ‎08-05-2002
Message 2 of 2 (178 Views)

Re: MLeaders

08-04-2009 01:53 PM in reply to: BrentBurgess1980
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...
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.