taoboq 发表于 2006-12-6 21:20:00

关于选择集的删除问题???

<P>(1)</P>
<P>Private Sub UserForm_Initialize()<BR>'清空选择集合中已有的选择集。避免重名<BR>&nbsp;&nbsp; Dim objSset As AcadSelectionSet<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; Dim Intstep As Integer<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; If ThisDrawing.SelectionSets.count &lt;&gt; 0 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;For Each objSset In ThisDrawing.SelectionSets<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objSset.Delete<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next objSset<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; <BR>End Sub</P>
<P>(2)<BR>Private Sub UserForm_Initialize()<BR>'清空选择集合中已有的选择集。避免重名<BR>&nbsp;&nbsp; Dim objSset As AcadSelectionSet<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; Dim Intstep As Integer<BR>&nbsp;&nbsp;&nbsp; If ThisDrawing.SelectionSets.count &lt;&gt; 0 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For Intstep = 0 To (ThisDrawing.SelectionSets.count - 1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set objSset = ThisDrawing.SelectionSets.Item(Intstep)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objSset.Delete<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; <BR>End Sub<BR></P>
<P>我用的事autocad2004</P>
<P>当我用第一种方法的时候,如果有选择集存在(即selectionsets.count&lt;&gt;0)就会只删除选择集(selectionset)到剩余最后一个,然后再往选择集(selectionsets)内添加重名的选择集(selectionset)时,系统就会报错,而且关掉了autocad的界面.</P>
<P>用第二种方法时就一切ok</P>
<P>哪位高手指点一下是为什么???</P>

worker 发表于 2006-12-8 02:26:00

<P>CAD的帮助文件中有这样的例子,用的不是你这样的方法,它的方法能具体的删除指定名字的选择集.</P>
<P>Dim SSblk As AcadSelectionSet</P>
<P>&nbsp;On Error Resume Next<BR>&nbsp;' Delete the selection set if it exists<BR>&nbsp;If Not IsNull(ThisDrawing.SelectionSets.Item("blk")) Then<BR>&nbsp;&nbsp;&nbsp; Set SSblk = ThisDrawing.SelectionSets.Item("blk")<BR>&nbsp;&nbsp;&nbsp; SSblk.Delete<BR>&nbsp;End If</P>
<P>Set SSblk = ThisDrawing.SelectionSets.Add("blk")<BR></P>

taoboq 发表于 2006-12-11 10:28:00

<p>我想要的是删除选择集,在不知道该选择集的名字的情况下,删除掉它,然后再建立一个新的选择集。</p>
页: [1]
查看完整版本: 关于选择集的删除问题???