Message 1 of 7

Not applicable
04-27-2020
10:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm using a spreadsheet to update my drawing based on the information there. Basically I'm looking for a text in Column 1, if any autocad object has this text it will be replaced by the Value in Column 2. My code works, but it runs very slow... it took 15minutes to do the job on a drawing with 3000 entities while my excel table has only 15 rows.
The "find" command in Autocad works faster, but the problem it shows a dialog box asking for amnual entry when I call it.
This is the part of my code that update the block and Mtexts... Any tip on how to improve it?
On Error Resume Next
For Each oBlock In acaddoc.Blocks
For i = 0 To oBlock.Count
If oBlock.Item(i).objectname = "AcDbBlockReference" Then
If (oBlock.Item(i).HasAttributes) Then
attr = oBlock.Item(i).getattributes()
For ii = 0 To UBound(attr)
For j = rwS To rwE 'Sets the Search Range, rwS-> first row in the spreadsheet, rwE-> last row
If InStr(1, attr(ii).TextString, Cells(j, col).Text, 1) Then
attr(ii).TextString = Replace(attr(ii).TextString, Cells(j, col).Text, Cells(j, col + 1).Text, , 1)
Exit For
End If
Next j
Next
End If
ElseIf oBlock.Item(i).objectname = "AcDbMText" Then
For j = rwS To rwE
If InStr(1, oBlock.Item(i).TextString, Cells(j, col).Text, 1) Then
oBlock.Item(i).TextString = Replace(oBlock.Item(i).TextString, Cells(j, col).Text, Cells(j, col + 1).Text, , 1)
End If
Next
'... continue code
end if
next i
next oBlock
Solved! Go to Solution.