Heres the same thing almost in VBA the original idea behind it was a single title block change no matter how many title blocks the extra code allows for pick a block that identifies the block name hope all this makes sense. Just run the add_project_number it will work with your block, change DA1DRTXT to your block name.
Code:
Public Sub add_project_number()
' This Updates the project number
Dim SS As AcadSelectionSet
Dim Count As Integer
Dim FilterDXFCode(1) As Integer
Dim FilterDXFVal(1) As Variant
Dim attribs, newtext As Variant
Dim BLOCK_NAME As String
'On Error Resume Next
Dim startCH As Double
newtext = ThisDrawing.Utility.GetString(True, "Enter new project code : ")
FilterDXFCode(0) = 0
FilterDXFVal(0) = "INSERT"
FilterDXFCode(1) = 2
FilterDXFVal(1) = "DA1DRTXT"
BLOCK_NAME = "DA1DRTXT"
Set SS = ThisDrawing.SelectionSets.Add("issued")
SS.Select acSelectionSetAll, , , FilterDXFCode, FilterDXFVal
For Cntr = 0 To SS.Count - 1
attribs = SS.Item(Cntr).GetAttributes
attribs(1).TextString = newtext
attribs(1).Update
Next Cntr
ThisDrawing.SelectionSets.Item("issued").Delete
End Sub
and
Code:
Function Getpitname(Newpitname As String) As String
Dim PitNameSelect As AcadObject
Dim pitattribs As Variant
ThisDrawing.Utility.GetEntity PitNameSelect, basepnt, "pick pit name : "
If PitNameSelect.ObjectName = "AcDbText" Then
Getpitname = PitNameSelect.TextString
End If
If PitNameSelect.ObjectName = "AcDbBlockReference" Then
pitblname = PitNameSelect.Name ' RETURNS BLOCK NAME
pitattribs = PitNameSelect.GetAttributes
Getpitname = pitattribs(0).TextString
End If
End Function
you need to change the line newtext = ThisDrawing.Utility.GetString(True, "Enter new project code : ") to
Code:
Dim PitNameSelect As AcadObject
ThisDrawing.Utility.GetEntity PitNameSelect, basepnt, "pick pit name : "
Newpitname = "1" 'dummy to pass then return changed
pitname = Getpitname(Newpitname)
'Call Getpitname(pitname)
MsgBox "pitname selected is " & pitname
Bookmarks