liuyang4740 发表于 2008-11-14 10:33:00

打断程序问题:有时候可以运行,有时候不能

<p>源程序如下:</p><p>Sub r4()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '打断<br/>&nbsp;&nbsp;&nbsp; Dim returnObj As AcadEntity<br/>&nbsp;&nbsp;&nbsp; Dim x(2), y(2) As Double<br/>&nbsp;&nbsp;&nbsp; Dim ss(100000) As Variant<br/>&nbsp;&nbsp;&nbsp; Dim det As String<br/>&nbsp;&nbsp;&nbsp; Dim det1 As String<br/>&nbsp;&nbsp;&nbsp; Dim lspPnt As String<br/>&nbsp;&nbsp;&nbsp; Dim minp, maxp As Variant<br/>&nbsp;&nbsp;&nbsp; Dim ssetobj, ssetobj2 As AcadSelectionSet<br/>&nbsp;&nbsp;&nbsp; Dim ent As AcadEntity<br/>&nbsp;&nbsp;&nbsp; 'ScreenUpdating = False<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; On Error Resume Next<br/>&nbsp;&nbsp;&nbsp; SsetName = "au100"<br/>&nbsp;&nbsp;&nbsp; On Error Resume Next<br/>&nbsp;&nbsp;&nbsp; For i = 0 To ThisDrawing.SelectionSets.Count - 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set ssetobj = ThisDrawing.SelectionSets.Item(i)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If ssetobj.Name = "au100" Then ssetobj.Delete<br/>&nbsp;&nbsp;&nbsp; Next i<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set ssetobj = ThisDrawing.SelectionSets.Add(SsetName)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ssetobj.SelectOnScreen<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; k = 0<br/>&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; j = ssetobj.Count<br/>&nbsp;&nbsp;&nbsp;&nbsp; For i = 0 To j - 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For ii = 0 To j - 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Abs(ssetobj.Item(i).Angle - ssetobj.Item(ii).Angle) &gt; 0.5 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ss(k) = ssetobj.Item(i).IntersectWith(ssetobj.Item(ii), acExtendBoth)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; det = GetDoubleEntTable(ssetobj.Item(i), ss(k))<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; det1 = GetDoubleEntTable(ssetobj.Item(ii), ss(k))<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lspPnt = axPoint2lspPoint(ss(k))<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.SendCommand "_break" &amp; vbCr &amp; det &amp; vbCr &amp; lspPnt &amp; vbCr<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.SendCommand "_break" &amp; vbCr &amp; det1 &amp; vbCr &amp; lspPnt &amp; vbCr<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; k = k + 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<br/>&nbsp;&nbsp;&nbsp;&nbsp; Next<br/>&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; SsetName = "au101"<br/>&nbsp;&nbsp;&nbsp; On Error Resume Next<br/>&nbsp;&nbsp;&nbsp; For i = 0 To ThisDrawing.SelectionSets.Count - 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set ssetobj2 = ThisDrawing.SelectionSets.Item(i)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If ssetobj2.Name = "au101" Then ssetobj2.Delete<br/>&nbsp;&nbsp;&nbsp; Next i<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set ssetobj2 = ThisDrawing.SelectionSets.Add(SsetName)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ssetobj2.SelectOnScreen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'删除打断中产生的小雨1000的直线<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For Each returnObj In ssetobj2<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If returnObj.Length &lt; 1000 Then returnObj.Delete<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; returnObj.color = acRed<br/>&nbsp;&nbsp; Next<br/>&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp; end&nbsp; sub</p><p><br/>'转换双元表的函数<br/>Public Function GetDoubleEntTable(entObj As AcadEntity, Pnt As Variant) As String<br/>&nbsp;&nbsp;&nbsp; Dim entHandle As String<br/>&nbsp;&nbsp;&nbsp; entHandle = entObj.Handle<br/>&nbsp;&nbsp;&nbsp; GetDoubleEntTable = "(list(handent " &amp; Chr(34) &amp; entHandle &amp; Chr(34) &amp; _<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ")(list " &amp; Str(Pnt(0)) &amp; Str(Pnt(1)) &amp; Str(Pnt(2)) &amp; "))"<br/>End Function</p><p>'转换点的函数</p><p>Public Function axPoint2lspPoint(Pnt As Variant) As String<br/>&nbsp;&nbsp;&nbsp; axPoint2lspPoint = Pnt(0) &amp; "," &amp; Pnt(1) &amp; "," &amp; Pnt(2)<br/>End Function</p><p>'转换图元函数</p><p>Public Function axEnt2lspEnt(entObj As AcadEntity) As String<br/>&nbsp;&nbsp;&nbsp; Dim entHandle As String<br/>&nbsp;&nbsp;&nbsp; entHandle = entObj.Handle<br/>&nbsp;&nbsp;&nbsp; axEnt2lspEnt = "(handent " &amp; Chr(34) &amp; entHandle &amp; Chr(34) &amp; ")"<br/>End Function</p>

liuyang4740 发表于 2008-11-20 12:24:00

高手请指教阿

mccad 发表于 2008-11-22 12:45:00

本帖最后由 作者 于 2008-11-22 12:45:37 编辑

关闭对象捕捉试试。另外屏幕外的对象是无法操作的。

liuyang4740 发表于 2008-11-25 09:55:00

还是不行啊,如果不建立第二个选择集,打断可以实现,建立第二个选择集之后,连打断都不能实现啊?请问楼上的,是否是选择集相冲突呢?
页: [1]
查看完整版本: 打断程序问题:有时候可以运行,有时候不能