Visual Basic Customization

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

MLeaders

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

You are not logged in.

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

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

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

Ask the Community