Sub addrec() Dim pt(1 To 2) As Variant Dim pt1(14) As Double Dim Recobj As AcadPolyline Dim l, s, XDiffer, YDiffer, sca As Double l = 5 pt(1) = ThisDrawing.Utility.GetPoint(, "请输入矩形第一条宽边的中心点") pt(2) = ThisDrawing.Utility.GetPoint(, "请输入矩形第二条宽边的中心点") XDiffer = pt(2)(0) - pt(1)(0) YDiffer = pt(2)(1) - pt(1)(1) s = (XDiffer ^ 2 + YDiffer ^ 2) ^ (1 / 2) sca = l / 2 / s pt1(0) = pt(1)(0) - YDiffer * sca pt1(1) = pt(1)(1) + XDiffer * sca pt1(2) = 0# pt1(3) = pt(1)(0) + YDiffer * sca pt1(4) = pt(1)(1) - XDiffer * sca pt1(5) = 0# pt1(6) = pt(2)(0) + YDiffer * sca pt1(7) = pt(2)(1) - XDiffer * sca pt1(8) = 0# pt1(9) = pt(2)(0) - YDiffer * sca pt1(10) = pt(2)(1) + XDiffer * sca pt1(11) = 0# pt1(12) = pt1(0) pt1(13) = pt1(1) pt1(14) = pt1(2) Set Recobj = ThisDrawing.ModelSpace.AddPolyline(pt1) Recobj.Update End Sub 写得不是太严谨,只是说明这样的程序是可以完成的,应该还有更好的办法,大家再琢磨吧 |