我有一个问题,有一个带有大量数据链接的自动加载文件,并且只想更新与特定表相关的数据链接。同样,选择具有数据链接的表的功能,右键单击和选择更新表数据链接。
我有以下代码:
Private Sub Update_table_data_link(tblRef As AcadTable)
ThisDrawing.SendCommand "DATALINKUPDATE" & vbCr & "U" & vbCr & "K" & vbCr
End Sub
它有效,但更新图纸中的所有数据链接(这是一个问题),因此一个完美的解决方案可以让我获得与tblRef
相关的链接
并将行更改为:
ThisDrawing.SendCommand "DATALINKUPDATE" & vbCr & "U" & vbCr & "D" & vbCr & "datalink_name_from_tblRef" & vbCr
或直接发送命令将链接更新为tblRef
在大量挖掘和很多帮助之后,这是答案:
Private Sub Update_table_data_link(tblRef As AcadTable)
ThisDrawing.SendCommand "DATALINKUPDATE " & vbCr & "U" & vbCr & Ent2lspEnt(tblRef) & vbCr & vbCr
End Sub
Public Function Ent2lspEnt(entObj As AcadEntity) As String
'Designed to work with SendCommand, which can't pass objects.
'This gets an objects handle and converts it to a string
'of lisp commands that returns an entity name when run in SendCommand.
Dim entHandle As String
entHandle = entObj.Handle
Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
End Function
请注意," update_table_data_link"的表格为输入