Ad

Tuesday, December 20, 2011

Mass MLeader Renumber

I wrote this code a while back that changes all of the MLeaders found in a drawing’s model space from an existing number to a new one. I’m just putting it here for a reminder later for when I may need it.

Sub ChangeMLeaderNumber()

Dim oAcadObject As AcadObject
Dim sOriginalNumber As String
Dim sChangedNumber As String
Dim oMLeader As AcadMLeader
Dim oAttDef As AcadAttribute

sOriginalNumber = ThisDrawing.Utility.GetString(1, "Enter existing MLeader Number to change: ")
sChangedNumber = ThisDrawing.Utility.GetString(1, "Enter new MLeader Number: ")

For Each oAcadObject In ThisDrawing.ModelSpace

If (TypeOf oAcadObject Is AcadMLeader) Then
Set oMLeader = oAcadObject

Dim sBlock As String
sBlock = oMLeader.ContentBlockName

Dim oEnt As AcadEntity
For Each oEnt In ThisDrawing.Blocks(sBlock)
If oEnt.ObjectName = "AcDbAttributeDefinition" Then
Set oAttDef = oEnt
If oAttDef.TagString = "CIRCLE" And oAttDef.TextString = sOriginalNumber Then
oMLeader.SetBlockAttributeValue oAttDef.ObjectID, sChangedNumber
End If
End If
Next
End If
Next

End Sub



The code was set up for the MLeader I was working with at the time. It would need to be changed to match the block you are using.

No comments:

LinkWithin

Blog Widget by LinkWithin

Ad