[VBA] 怎么样已有的选择集中移除掉一些内容
<P>请问:</P><P>现有的选择集中有一些实体内容,我想用一个for each ……next 从中判断把不符合条件的内容从选择集中移除掉,应该怎么操作?</P> <P>9 For k = 0 To SelectionSet.Count - 1<BR> If (你的条件) Then<BR> ReDim deleteObj(0) As Object<BR> Set deleteObj(0) = SelectionSet.Item(k)<BR> SelectionSet.RemoveItems deleteObj<BR> GoTo 9<BR> End If<BR> Next</P>
<P>呵呵!大体是这样的...你看看吧^_^</P>
<P> </P> 谢谢啦! 本帖最后由 WarpSkyMapping 于 2013-3-11 17:07 编辑
Sub RemoveSsetsObjects()
' ´ÓÑ¡Ôñ¼¯ÖÐÒƳý¶ÔÏó
On Error Resume Next
Dim sset As AcadSelectionSet
Set sset = ThisDrawing.SelectionSets.Add("SS4")
sset.SelectOnScreen
MsgBox sset.Count
Dim Ent As AcadObject
Dim deleteObj() As Object
k = 0
For Each Ent In sset
If Ent.Layer = "0" Then
ReDim Preserve deleteObj(k) 'As Object
Set deleteObj(k) = Ent
k = k + 1
End If
Next
sset.RemoveItems deleteObj
MsgBox sset.Count
sset.Delete
End Sub
页:
[1]