明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1290|回复: 3

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

[复制链接]
发表于 2008-11-14 10:33:00 | 显示全部楼层 |阅读模式

源程序如下:

Sub r4()                          '打断
    Dim returnObj As AcadEntity
    Dim x(2), y(2) As Double
    Dim ss(100000) As Variant
    Dim det As String
    Dim det1 As String
    Dim lspPnt As String
    Dim minp, maxp As Variant
    Dim ssetobj, ssetobj2 As AcadSelectionSet
    Dim ent As AcadEntity
    'ScreenUpdating = False
   
    On Error Resume Next
    SsetName = "au100"
    On Error Resume Next
    For i = 0 To ThisDrawing.SelectionSets.Count - 1
        Set ssetobj = ThisDrawing.SelectionSets.Item(i)
       If ssetobj.Name = "au100" Then ssetobj.Delete
    Next i
       Set ssetobj = ThisDrawing.SelectionSets.Add(SsetName)
       ssetobj.SelectOnScreen
     
       k = 0
 
       j = ssetobj.Count
     For i = 0 To j - 1
        For ii = 0 To j - 1
          If Abs(ssetobj.Item(i).Angle - ssetobj.Item(ii).Angle) > 0.5 Then
            ss(k) = ssetobj.Item(i).IntersectWith(ssetobj.Item(ii), acExtendBoth)
            det = GetDoubleEntTable(ssetobj.Item(i), ss(k))
            det1 = GetDoubleEntTable(ssetobj.Item(ii), ss(k))
            lspPnt = axPoint2lspPoint(ss(k))
            ThisDrawing.SendCommand "_break" & vbCr & det & vbCr & lspPnt & vbCr
            ThisDrawing.SendCommand "_break" & vbCr & det1 & vbCr & lspPnt & vbCr
            k = k + 1
          End If
        Next
     Next
    
    SsetName = "au101"
    On Error Resume Next
    For i = 0 To ThisDrawing.SelectionSets.Count - 1
        Set ssetobj2 = ThisDrawing.SelectionSets.Item(i)
       If ssetobj2.Name = "au101" Then ssetobj2.Delete
    Next i
       Set ssetobj2 = ThisDrawing.SelectionSets.Add(SsetName)
                        
          ssetobj2.SelectOnScreen          '删除打断中产生的小雨1000的直线
      For Each returnObj In ssetobj2
      If returnObj.Length < 1000 Then returnObj.Delete
      returnObj.color = acRed
   Next
   
   end  sub


'转换双元表的函数
Public Function GetDoubleEntTable(entObj As AcadEntity, Pnt As Variant) As String
    Dim entHandle As String
    entHandle = entObj.Handle
    GetDoubleEntTable = "(list(handent " & Chr(34) & entHandle & Chr(34) & _
                     ")(list " & Str(Pnt(0)) & Str(Pnt(1)) & Str(Pnt(2)) & "))"
End Function

'转换点的函数

Public Function axPoint2lspPoint(Pnt As Variant) As String
    axPoint2lspPoint = Pnt(0) & "," & Pnt(1) & "," & Pnt(2)
End Function

'转换图元函数

Public Function axEnt2lspEnt(entObj As AcadEntity) As String
    Dim entHandle As String
    entHandle = entObj.Handle
    axEnt2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
End Function

 楼主| 发表于 2008-11-20 12:24:00 | 显示全部楼层
高手请指教阿
发表于 2008-11-22 12:45:00 | 显示全部楼层
本帖最后由 作者 于 2008-11-22 12:45:37 编辑

关闭对象捕捉试试。另外屏幕外的对象是无法操作的。
 楼主| 发表于 2008-11-25 09:55:00 | 显示全部楼层
还是不行啊,如果不建立第二个选择集,打断可以实现,建立第二个选择集之后,连打断都不能实现啊?请问楼上的,是否是选择集相冲突呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 06:35 , Processed in 0.165415 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表