zxj_76 发表于 2005-12-14 10:25:00

[VBA] 怎么样已有的选择集中移除掉一些内容

<P>请问:</P>
<P>现有的选择集中有一些实体内容,我想用一个for each ……next 从中判断把不符合条件的内容从选择集中移除掉,应该怎么操作?</P>

xinghesnak 发表于 2005-12-14 14:52:00

<P>9&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;For k = 0 To SelectionSet.Count - 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;(你的条件) Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ReDim deleteObj(0) As Object<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set deleteObj(0) = SelectionSet.Item(k)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SelectionSet.RemoveItems deleteObj<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GoTo 9<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Next</P>
<P>呵呵!大体是这样的...你看看吧^_^</P>
<P>&nbsp;</P>

zxj_76 发表于 2005-12-14 15:33:00

谢谢啦!

WarpSkyMapping 发表于 2013-3-11 17:05:40

本帖最后由 WarpSkyMapping 于 2013-3-11 17:07 编辑


Sub RemoveSsetsObjects()
' &acute;&Oacute;&Ntilde;&iexcl;&Ocirc;&ntilde;&frac14;&macr;&Ouml;&ETH;&Ograve;&AElig;&sup3;&yacute;&para;&Ocirc;&Iuml;ó
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]
查看完整版本: [VBA] 怎么样已有的选择集中移除掉一些内容