sus1982 发表于 2006-1-2 23:19:00

快帮我看看这个有关"选择集"子程序怎么运行不了啊???

<P>下面编码先判断选择集是否存在再对其操作,可运行后老是弹出"未找到关键字"的错误信息.就是不知道问题出在哪里?请高手帮我看看!!!</P>
<P>Sub addrelativitylin()<BR>&nbsp;&nbsp; Dim lineSelection1 As AcadSelectionSet<BR>&nbsp;&nbsp; If Not IsNull(ThisDrawing.SelectionSets.Item("lineSelection1")) Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set lineSelection1 = ThisDrawing.SelectionSets.Item("NewSelectionSet")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; selset.Delete<BR>&nbsp;&nbsp; End If<BR>&nbsp;&nbsp; Set lineSelection1 = ThisDrawing.SelectionSets.Add("NewSelectionSet")<BR>&nbsp;&nbsp; MsgBox "the new is" &amp; lineSelection1.Name, vbInformation, "SelectionSets Example"<BR>End Sub</P>

zhuxuhong 发表于 2006-1-3 10:03:00

selset.Delete 改为lineSelection1.delete 试试

sus1982 发表于 2006-1-3 10:42:00

<P>不行啊,用楼上的方法还是出现弹出"未找到关键字"的错误信息. </P>
<P>调试的时候提示好象是" If Not IsNull(ThisDrawing.SelectionSets.Item("lineSelection1")) Then" 这里出了什么问题!</P>
<P>&nbsp;可就是不知道在哪里出了问题</P>
<P>&nbsp;</P>

zhuxuhong 发表于 2006-1-3 10:49:00

<DIV>Function CreateSelectionSet(Optional SSetName As String = "mjtd") As AcadSelectionSet<BR>&nbsp;&nbsp;&nbsp;&nbsp;On Error Resume Next<BR>&nbsp;&nbsp;&nbsp;&nbsp;ThisDrawing.SelectionSets(SSetName).Delete<BR>&nbsp;&nbsp;&nbsp;&nbsp;Set CreateSelectionSet = ThisDrawing.SelectionSets.Add(SSetName)<BR>End Function</DIV>
<DIV>用这段试试</DIV>

sus1982 发表于 2006-1-3 11:43:00

<P>用"On Error Resume Next" 可以了</P>
<P>谢谢楼上大哥了<BR></P>

sus1982 发表于 2006-1-3 12:38:00

<P>我用Sset.SelectOnScreen给新建的选择集添加对象,可老是选不上对象,下面代码没反应,请高手们帮我看看把</P>
<P>Sub addrelativityline()<BR>&nbsp;&nbsp; Dim lineSelection1 As AcadSelectionSet<BR>&nbsp;&nbsp; On Error Resume Next<BR>&nbsp;ThisDrawing.SelectionSets("SSl").Delet<BR>&nbsp;&nbsp; Set lineSelection1 = ThisDrawing.SelectionSets.Add("SSl")<BR>&nbsp;&nbsp; Sset.SelectOnScreen<BR>&nbsp;&nbsp; ThisDrawing.ModelSpace.lineSelection1.Erase<BR>End Sub</P>
页: [1]
查看完整版本: 快帮我看看这个有关"选择集"子程序怎么运行不了啊???