本帖最后由 作者 于 2008-9-17 22:09:27 编辑
图示,求C点到AB线段的垂线,且交点于B点. 程序解决如下 Sub LS() Sub LS() Dim Aa(2) As Variant Aa(0) = Array(10, 33) Aa(1) = Array(20, 50) Aa(2) = Array(25, 50) Dim pp(0 To 2) As Double, ppp(0 To 2) As Double Dim Alfa(1) As Double, ll As AcadLine For ii = 0 To 1 For jj = 0 To 1 pp(jj) = Aa(ii)(jj) ppp(jj) = Aa(ii + 1)(jj) Next jj Set ll = ThisDrawing.ModelSpace.AddLine(pp, ppp) Alfa(ii) = ll.Angle Next ii Debug.Print Alfa(1), Alfa(0) * 180 / 3.1415926, Alfa(1) - Alfa(0) Debug.Print Alfa(0) - Pi / 2, (Alfa(0) - Pi / 2) * 180 / Pi ll.Rotate ll.StartPoint, Alfa(0) - Pi / 2 End Sub Function Pi() As Double Pi = 4 * Atn(1) End Function |