[求助]运行后选择集.count=0该怎么办
本帖最后由 作者 于 2010-4-14 20:07:10 编辑 <br /><br /> <p>大家好!最近编的程序含选择集的部分如下所示。有两个问题请教高人:</p><p>(1)调试过程是用一个正方形和4个孤立点的。case 1的调试过程中,设置了Sset.count为参数,发现一直为0,不知道哪里出错?</p><p>(2)case 2运行中,jh_dian.count正常,大方向没问题。但粗线部分该怎么写啊?就是说令Shy=该图元的类型该用何语句?</p><p>在此先多谢各位不吝指教了!</p><p>Dim Sset As AcadSelectionSet<br/>Dim insPoint As Variant<br/>Dim KeyWord As String</p><p>On Error Resume Next<br/>Set Sset = ThisDrawing.SelectionSets.Add("mky")<br/>If Err Then<br/> Err.Clear<br/> Set Sset = ThisDrawing.SelectionSets.Item("mky")<br/> Sset.Clear<br/>End If<br/>'新建空选择集</p><p>ThisDrawing.Utility.InitializeUserInput 0, "1 2"<br/>KeyWord = ThisDrawing.Utility.GetKeyword(vbCrLf & "选择选点方式:(1)在屏幕上直接指点;(2)一次性框选点 <1>")<br/>If KeyWord = "" Then KeyWord = "1"<br/>Select Case KeyWord<br/> Case "1"<br/> Do<br/> insPoint = ThisDrawing.Utility.GetPoint(, "请在屏幕上指定点(右键退出):")<br/> If Not (Err.Number = 13 Or Err.Number = -2145320928) Then<br/> Sset.Add insPoint<br/> End If<br/> Loop Until Err.Number = 13 Or Err.Number = -2145320928<br/> Err.Clear<br/> Case "2"<br/> Dim PointOBj As AcadBlockReference<br/> Dim Point As AcadPoint<br/> Dim TemPnt(0 To 1) As Double<br/> Dim jh_dian As AcadSelectionSet<br/> Call Addselection(jh_dian, "JH_Dian")<br/> Dim FilterType(6) As Integer<br/> Dim FilterData(6) As Variant<br/> Dim layername As String<br/> layername = ThisDrawing.ActiveLayer.Name<br/> FilterType(0) = -4<br/> FilterData(0) = "<and"<br/> FilterType(1) = -4<br/> FilterData(1) = "<or"<br/> FilterType(2) = 0<br/> FilterData(2) = "point"<br/> FilterType(3) = 2<br/> FilterData(3) = "block"<br/> FilterType(4) = -4<br/> FilterData(4) = "or>"<br/> FilterType(5) = 8<br/> FilterData(5) = layername<br/> FilterType(6) = -4<br/> FilterData(6) = "and>"</p><p> ThisDrawing.Utility.Prompt vbCrLf + "请从屏幕上选取点!" + vbCrLf<br/> jh_dian.SelectOnScreen FilterType, FilterData<br/> Dim Sty As String<br/> Dim i As Long<br/> For i = 0 To (jh_dian.Count - 1)<br/> <strong>Sty = jh_dian.Item(i).HasExtensionDictionary<br/></strong> If Sty = "Point" Then<br/> Set Point = jh_dian.Item(i)<br/> TemPnt(0) = Point.Coordinates(0)<br/> TemPnt(1) = Point.Coordinates(1)</p><p> Else<br/> Set PointOBj = jh_dian.Item(i)<br/> TemPnt(0) = PointOBj.InsertionPoint(0)<br/> TemPnt(1) = PointOBj.InsertionPoint(1)</p><p> End If<br/> Sset.Add TemPnt<br/> Next<br/> jh_dian.Delete<br/>End Select<br/>If Sset.Count = 0 Then<br/> Sset.Delete<br/> MsgBox "已选取 0 个点,不能生成表格。", vbExclamation<br/> Exit Sub<br/>End If<br/>ThisDrawing.Utility.Prompt vbCrLf + "命令:你在屏上选定了" & Sset.Count & "个坐标点 " + vbCrLf</p> <p>你的过滤器写的有问题,要选择的是什么样实体的?</p>
页:
[1]