Sub fangweijiao()
'定义直线的起点与终点
Dim startpoint As Variant
Dim endpoint As Variant
'定义两个提示语句
Dim prompt1 As String
Dim prompt2 As String
prompt1 = vbCrLf & "输入直线的起点:"
prompt2 = vbCrLf & "输入直线的终点:"
'获取点
startpoint = ThisDrawing.Utility.GetPoint(, prompt1)
endpoint = ThisDrawing.Utility.GetPoint(startpoint, prompt2)
'创建直线
ThisDrawing.ModelSpace.AddLine startpoint, endpoint
'计算直线与X周的夹角
Dim angle As Double
angle = ThisDrawing.Utility.AngleFromXAxis(startpoint, endpoint)
'换算方位角
Dim fangweijiao As Double
fangweijiao = angle * 180 / 3.14159265358979 - 90
'提示输出
MsgBox "直线方位角为" & fangweijiao, , "FangWeiJiao"
ZoomAll
End Sub