本帖最后由 作者 于 2008-10-25 23:41:56 编辑
说明:该块实际值分别应为 Px1=(-2,0,0) Px2=(2,0,0) Py1=(0,-2,0) Py2=(0,2,0) 但程序得到的结果却各有2个交点,且Px2为(5.27,0,0)和Py2为(0,5.5488,0) 我程序如下: Sub getxy() Dim Blk As AcadBlockReference Dim P1(0 To 2) As Double Dim Pa As Variant Dim Pb(0 To 2) As Double Dim Px1 As Variant Dim Px2 As Variant Dim Py1 As Variant Dim Py2 As Variant Dim Linet As AcadLine Dim blkname As String blkname = "d:\lks.dwg" P1(0) = 0 P1(1) = 0 P1(2) = 0 Pa = P1 Pb(0) = 50 '块的高和宽均不会大于50,且块的原点在坐标(0,0,0) Pb(1) = 0 Pb(2) = 0 Set Blk = ThisDrawing.ModelSpace.InsertBlock(Pa, blkname, 1, 1, 1, 0) Set Linet = ThisDrawing.ModelSpace.AddLine(Pa, Pb) Px2 = Blk.IntersectWith(Linet, acExtendNone) Pb(0) = -50 Linet.EndPoint = Pb Px1 = Blk.IntersectWith(Linet, acExtendNone) Pb(0) = 0 Pb(1) = -50 Linet.EndPoint = Pb Py1 = Blk.IntersectWith(Linet, acExtendNone) Pb(1) = 50 Linet.EndPoint = Pb Py2 = Blk.IntersectWith(Linet, acExtendNone) Linet.Delete Blk.Delete End Sub
|