[求助]怎样判断一个选择集是否存在啊
<INPUT class=btn style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体" onclick="text1.style.fontSize='12pt';" type=button value=12号字> <OPTION value="9pt">9pt</OPTION> <OPTION value="10pt" selected>10pt</OPTION> <OPTION value="11pt">11pt</OPTION> <OPTION value="12pt">12pt</OPTION> <OPTION value="13pt">13pt</OPTION> <OPTION value="15pt">15pt</OPTION> <FONT id=text1 style="FONT-SIZE: 10pt" face="宋体,verdana, arial, helvetica"><BR>Dim sset As AcadSelectionSet<BR>‘在添加以前加个判断语句,看test是否存在<BR>(1)<BR>Set sset = acadApp.ActiveDocument.SelectionSets.Add("test")<BR>sset.SelectOnScreen<BR>If IsNull(acadApp.ActiveDocument.SelectionSets.item("test")) Then Exit Sub<BR>Set frm_chamfer_objcs.sset = sset<BR>frm_chamfer_objcs.Show<BR>(2)<BR>acadApp.ActiveDocument.SelectionSets("test").Delete加在(2)的位置,frm_chamfer_objcs.sset 的窗体中的选择集变成nothing了<BR>加在(1)那位置呢,第一次执行会出错,以后就好了<BR><BR>最好是有个语名判断选择集是否存在</FONT> 给一个函数给你参考,里面有判断的语句。Public Function CreateSelectionSet(Optional ssName As String = "ss") As AcadSelectionSet<BR> '返回一个空白选择集<BR> <BR> Dim ss As AcadSelectionSet<BR> <BR> On Error Resume Next<BR> Set ss = ThisDrawing.SelectionSets(ssName)<BR> If Err Then Set ss = ThisDrawing.SelectionSets.Add(ssName)<BR> ss.Clear<BR> Set CreateSelectionSet = ss<BR>End Function 非常感谢 <P>选择集有Bug,使用前必须调用Delete方法删除掉</P>
<P>不需<FONT size=2>判断选择集是否存在</FONT></P>
<P><FONT size=2>直接这样就可以了:</FONT></P>
<P><FONT size=2>on error resume next</FONT></P>
<P>ThisDrawing.SelectionSets("test").delete</P>
<P>set ss=ThisDrawing.SelectionSets.add("test")</P>
页:
[1]