你的程序是怎样的,我试过了,正常,没出现你说的现象。
- ' 主程序
- Sub DispBreakMun()
- Debug.Print "打断前的图元数目:" & ThisDrawing.ModelSpace.Count
- Call Break
- Debug.Print "打断后的图元数目:" & ThisDrawing.ModelSpace.Count
- End Sub
- '示例Break
- Sub Break()
- Dim Pnt As Variant
- Dim entObj As AcadEntity
- ThisDrawing.Utility.GetEntity entObj, Pnt, "选择图元:"
- Dim Pnt2 As Variant
- Pnt2 = ThisDrawing.Utility.GetPoint(, "选择点:")
- Dim det As String
- det = GetDoubleEntTable(entObj, Pnt)
- Dim lspPnt As String
- lspPnt = axPoint2lspPoint(Pnt2)
- ThisDrawing.SendCommand "_break" & vbCr & det & vbCr & lspPnt & vbCr
- End Sub
- '示例Trim
- Sub Trim()
- Dim Pnt1 As Variant
- Dim entObj1 As AcadEntity
- ThisDrawing.Utility.GetEntity entObj1, Pnt1, "选择图元:"
- Dim det1 As String
- det1 = axEnt2lspEnt(entObj1)
- Dim Pnt2 As Variant
- Dim entObj2 As AcadEntity
- ThisDrawing.Utility.GetEntity entObj2, Pnt2, "选择被剪图元:"
- Dim det2 As String
- det2 = GetDoubleEntTable(entObj2, Pnt2)
- ThisDrawing.SendCommand "_trim" & vbCr & det1 & vbCr & vbCr & det2 & vbCr & vbCr
- 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
|