CAD中文字查找替换功能如何用VBA实现

CAD里面的全图文字替换功能,请问用VBA程序是怎么写的。我想了解一下。在CAD中用“编辑”-“查找”,可以实现全图中任意文字查找替换,我现在要制作VBA软件来开发CAD,需要这个功能,请教大家谁能把CAD这个功能的VBA程序写给我,应该不难,只是我不知道,谢谢哈。我出高分的哈。
二楼的朋友,答案有点问题就是,图中右下角通常有材料表或者是部件表,就通过你的方法找不到。是怎么回事?

基本是这样子的
dim strDwgName As String
dim strFind As String
dim strReplace As String
Dim ent As AcadEntity
For Each ent In Thisdrawing.ModelSpace
If TypeOf ent Is AcadText Or TypeOf ent Is AcadMText Then
With ent
If InStr(.TextString, strFind) Then .TextString = ReplaceStr(.TextString, strFind, strReplace, False)
End With
End If
Next ent

补充:你那个不能改的标题栏可能是插入的属性块,是属性块里面的属性的文字,这个不能进入块中修改,只能在对象中。

strFind = "耳板"
Dim objBlkRef As AcadBlockReference
Dim varAttributes '取得块属性,显示属性标签和值

For Each ent In ThisDrawing.ModelSpace
If TypeOf ent Is AcadBlockReference Then
Set objBlkRef = ent
varAttributes = objBlkRef.GetAttributes
If UBound(varAttributes) Then
For i = 0 To UBound(varAttributes)
If varAttributes(i).TextString = strFind Then
varAttributes(i).TextString = "strFind"
End If
Next i
End If

End If
Next ent

这样可以替换块中的文字
温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-06-24
应该对块内,表内的文字再遍历一次修改就可以了。
第2个回答  2009-06-23
哎呀,看到这个问题真实亲切啊,想当年我第一个公司就是做这个的,哈哈,现在好久没听别人提过了,不过我也不会,嘿嘿,早忘没了
相似回答