- Public Sub DeleteAllObjXData() '删除多个对象的所有扩展数据
-
- Dim SSet As AcadSelectionSet
- For Each SSet In ThisDrawing.SelectionSets
- If SSet.name = "SS1" Then
- ThisDrawing.SelectionSets.Item("SS1").Delete
- Exit For
- End If
- Next
- Set SSet = ThisDrawing.SelectionSets.Add("SS1")
- SSet.SelectOnScreen
- ' 定义扩展数据变量以保存扩展数据信息
- Dim XdataType As Variant
- Dim xdata As Variant
- Dim xd As Variant
-
- Dim DataType(0) As Integer
- Dim Data(0) As Variant
-
- '定义索引计数器
- Dim xdi As Integer
- xdi = 0
- ' 遍历选择集中的对象
- ' 并检索对象的扩展数据
- Dim strAppName As String
- Dim objEnt As AcadEntity
- strAppName = ""
- For Each objEnt In SSet
- xdi = 0
- ' 检索 appName 扩展数据类型和值
- objEnt.GetXData strAppName, XdataType, xdata
- ' 如果未初始化 xdataType 变量,
- ' 则没有可供该图元检索的 appName 扩展数据
- If VarType(XdataType) <> vbEmpty Then
- For Each xd In XdataType
- If StrComp(XdataType(xdi), "1001", vbTextCompare) = 0 Then
- DataType(0) = 1001
- Data(0) = xdata(xdi)
- objEnt.SetXData DataType, Data
- End If
- xdi = xdi + 1
- Next xd
- End If
- ThisDrawing.Utility.Prompt "消除扩展数据成功!" & vbCrLf
- Next objEnt
- End Sub
|