花生 发表于 2004-1-29 20:17:00

myfreemind 发表于 2004-1-29 20:51:00

aaa是选择集的名称,第二次是因为aaa已经存在了,所以会出错!

ahlzl 发表于 2004-1-29 21:27:00

这样写代码,第一种方法: Sub a()
Dim n As Integer
n = ThisDrawing.SelectionSets.Count
While (n > 0)
If ThisDrawing.SelectionSets.Item(n - 1).Name = "aaa" Then
ThisDrawing.SelectionSets.Item(n - 1).Delete
n = n - 1
End If
Wend
Dim aa As AcadSelectionSet
Set longSelectionSet = ThisDrawing.SelectionSets.Add("aaa")
longSelectionSet.SelectOnScreen
End Sub第二种方法: Sub a()
On Error Resume Next
Dim longSelectionSet As AcadSelectionSet
ThisDrawing.SelectionSets("aaa").Delete
If Error Then
Err.Clear
End If
Set longSelectionSet = ThisDrawing.SelectionSets.Add("aaa")
longSelectionSet.SelectOnScreen
End Sub

bluemoon 发表于 2004-2-2 20:59:00

明经函数里有创建空的选择集的函数 已经有出错处理 你可以看看
页: [1]
查看完整版本: 如何向集合里面加东西亚???