Visual Basic Customization

Posts: 161
Registered: ‎06-16-2008
Message 1 of 2 (160 Views)


160 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

Distinguished Contributor
Posts: 104
Registered: ‎08-05-2002
Message 2 of 2 (160 Views)

Re: MLeaders

08-04-2009 01:53 PM in reply to: BrentBurgess1980

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...

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you interested in helping shape the Autodesk Community?
We’re looking at a few different ways to improve the “All Forums” landing page and need your feedback! If interested, please take a few minutes to fill out the following Usability Study. Thank you for your time!

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community