- 积分
- 12459
- 明经币
- 个
- 注册时间
- 2003-5-28
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2004-10-31 21:45:00
|
显示全部楼层
回复
参考:
Public Sub test() Dim ssetObj As AcadSelectionSet Set ssetObj = CreateSSet("Test") Dim mode As Integer mode = acSelectionSetAll '选择所有实体 ssetObj.Select mode MsgBox ssetObj.Count '如果选择集不为空,移除第一个实体 If ssetObj.Count > 0 Then Dim removeObjects(0) As AcadEntity Set removeObjects(0) = ssetObj(0) ssetObj.RemoveItems removeObjects MsgBox ssetObj.Count End If ssetObj.Clear ssetObj.Delete End Sub
'--------------------------------------------------------------------- ' '[函数] 创建选择集, 返回选择集对象 ' '---------------------------------------------------------------------
Private Function CreateSSet(ByVal name As String) As AcadSelectionSet On Error GoTo ERR_HANDLER Dim ssetObj As AcadSelectionSet Dim SSetColl As AcadSelectionSets Set SSetColl = ThisDrawing.SelectionSets Dim index As Integer Dim found As Boolean found = False
For index = 0 To SSetColl.Count - 1 Set ssetObj = SSetColl.Item(index) If StrComp(ssetObj.name, name, 1) = 0 Then found = True Exit For End If Next If Not (found) Then Set ssetObj = SSetColl.Add(name) Else ssetObj.Clear ' ssetObj.Delete ' Set ssetObj = SSetColl.Add(name) End If Set CreateSSet = ssetObj Exit Function ERR_HANDLER: '----------------------------------------------- ' just print the error the the debug window. Debug.Print "Error in sub CreateSSet: " & Err.Number & " -- "; Err.Description Resume ERR_END ERR_END: End Function
|
|