本帖最后由 作者 于 2006-8-24 9:36:16 编辑
vb6的程序过程:已经画了几个圆,现在画条直线,然后作该直线的偏移阵列,最后用sendcommand命令修剪圆外的直线,只留圆内的直线。
问题:见附件,无论怎么改程序,蓝色虚线的部分无法剪切掉。圆的下部的也剪切不掉。请高手指点。cad2002图
Dim Copyline As AcadLine Dim spoint(0 To 2) As Double, epoint(0 To 2) As Double Dim Rectangularline() As Object dim i as integer spoint(0) = -3 * hjw / 2: spoint(1) = R: spoint(2) = 0 epoint(0) = -3 * hjw / 2: epoint(1) = -R: epoint(2) = 0 Set Copyline = AcadDoc.ModelSpace.AddLine(spoint, epoint)
NumberOfRows = 1: NumberOfColumns = 0.5 * (hjks + 1) + 2: NumberOfLevels =1 DistBetweenRows = 1: DistBetweenColumns = hjw: DistBetweenLevels = 0 Rectangularline = Copyline.ArrayRectangular(NumberOfRows, NumberOfColumns, NumberOfLevels, DistBetweenRows, DistBetweenColumns, DistBetweenLevels)
For i = LBound(Rectangularline, 1) To UBound(Rectangularline, 1) '阵列产生对象数组 Rectangularline(i).Layer = "主体" Next i Dim det1 As String Dim det2 As String'不希望与cad互动,直接自己画图,剪切。 For i = LBound(Rectangularline, 1) To UBound(Rectangularline, 1) det1 = axEnt2lspEnt(objcir2)'objcir2是个圆 det2 = GetDoubleEntTable(Rectangularline(i), Rectangularline(i).StartPoint) AcadDoc.SendCommand "_trim" & vbCr & det1 & vbCr & vbCr & det2 & vbCr & vbCr Next i 以下是子函数:是AutoCAD vba 二次开发教程上的。 Public Function GetDoubleEntTable(ByVal entObj As Object, ByVal 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 axEnt2lspEnt(ByVal entObj As Object) As String Dim entHandle As String entHandle = entObj.Handle axEnt2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")" End Function
|