Ad

Friday, May 09, 2014

Change MLeader Number

Here is some old VBA code for changing mleader numbers.

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

No comments:

LinkWithin

Blog Widget by LinkWithin

Ad