求助斑竹:清华天河中修改明细表块参照属性一问
我用GetAttributes获得函数后,将其中的块参照的TextString属性修改了,可在图中看到改变后的结果,但是当我把明细表刷新或重新生成明细表后,TextString属性又改回去了 看看你的代码?重新生成明细表当然不会修改了,TextString是针对不同的块参照有不同的值
另外,你定义的属性是固定属性? 代码如下:
Sub rename()
'定义变量
Dim elem As Object '定义一个对象
Dim varAttributes As Variant '定义一个属性变量
Dim OldName As String
Dim NewName As String
Dim CgName As String
Dim L As Integer
Dim LL As Integer
Dim LLL As Integer
Dim number As Integer
Dim I As Integer
Dim found As Boolean
Static sset As AcadSelectionSet
Dim sss1 As AcadSelectionSet
Dim ObjSelectionSet As AcadSelectionSet
found = False
I = 0
'获取当前文件名
NewName = ThisDrawing.Name
L = Len(NewName)
NewName = Left(NewName, L - 4)
'获取当前文档标题栏中的图号
On Error Resume Next
Dim fft(1) As Integer, ffd(1)
ThisDrawing.SelectionSets("ss").Delete
Set sset = ThisDrawing.SelectionSets.Add("ss")
fft(0) = 0: ffd(0) = "Insert"
fft(1) = 2: ffd(1) = "PC_TITLE_BLOCK"
sset.Select acSelectionSetAll, , , fft, ffd
varAttributes = sset.Item(0).GetAttributes
OldName = varAttributes(4).TextString
'选择明细表
On Error Resume Next
Dim ss1 As AcadSelectionSet
Dim ft(1) As Integer, fd(1)
ThisDrawing.SelectionSets("*TlsTest*").Delete
Set ss1 = ThisDrawing.SelectionSets.Add("*TlsTest*")
ft(0) = 0: fd(0) = "Insert"
ft(1) = 2: fd(1) = "PC_MXB_BLOCK"
ss1.Select acSelectionSetAll, , , ft, fd
'修改明细表和标题
For Each elem In ss1
varAttributes = elem.GetAttributes
CgName = varAttributes(1).TextString
L = Len(NewName)
LL = Len(OldName)
LLL = Len(CgName)
If OldName = Left(CgName, LL) Then
CgName = Right(CgName, LLL - LL)
CgName = NewName & CgName
varAttributes(1).TextString = CgName
elem.Update
End If
Next
For Each elem In sset
varAttributes = elem.GetAttributes
varAttributes(4).TextString = NewName
Next
'删除标题栏和明细表选择集
ThisDrawing.SelectionSets("*TlsTest*").Delete
ThisDrawing.SelectionSets("ss").Delete
End Sub
举例说明一下该代码主要目的:
有一dwg文件,文件保存为ZJ40DBST,则文件的图样代号也为ZJ40DBST,明细表中代号也以ZJ40DBST开头来排序,但当我想把ZJ40DBST改为ZJ70LDB时,只需改一下保存的文件名,然后打开ZJ70LDB文件,运行上面的代码即可,但修改是针对天河PCCAD2002所写代码,故需在PCCAD2002下才能发现该情况,谢谢! 是天河PCCAD2002自动把属性又改回去了?
如果是的话就不好办了 你说的对,我用上面的代码虽然能改明细表,也能看到修改的结果,但用天河的明细表刷新,数据就又改回去了,我不知道天河把数据存在什么地方(但绝对在图中,不会另外存一处,我做过实验) 怎么解决,请斑竹帮忙想想办法呀! 天河将标题栏和明细表的数据存放在数据库中,所以当你用天河的工具打开时,它会自动恢复到原来的样子.这样你只更改属性块中的属性是不行的. 那又怎么解决数据库的问题,请提示,谢谢 这个最好是向天河公司咨询了.
我改INTECAD就是这样,更麻烦.国产的开发商故意把那些属性搞得很罗嗦,让别人无法集成.真是悲哀呀.以后市场只有越来越小. 谢谢你,不过我用的是D版,不好去咨询,如果你有了解决办法。麻烦告诉我一声。
页:
[1]