English

How To: Measure azimuth in degrees in your view

Procedure

Summary

The scripts in this document allow you to measure azimuth in degrees between points in a view.

Solution

These scripts use a point graphic and the ArcView status bar to perform the measurement.

1. Open three new script windows.

2. Copy each of the scripts below into a script window.

3. Select Properties from the Script menu and rename each script; aaPoint, aaPaint, and aaTimer respectively.

4. Assign the aaPoint script to the "Apply" property of a new tool on the View GUI.

5. Click the New tool and then click anywhere in the View. The script will place a graphic point where you clicked. The status bar will dynamically display the azimuth in degrees between the graphic point and the current location of the cursor.

Code:
'Script: aaPoint
'
theView = av.getactivedoc
theGL = theView.GetGraphics
theDisplay = theView.GetDisplay
_p1 = theDisplay.ReturnUserPoint
_pg1 = GraphicShape.Make(_p1)
theGL.Add(_pg1)
_pg1.Invalidate
_angle = 0
av.DelayedRun("aaPaint", nil, 1)
'
'End of Script: aaPoint


Code:
'Script: aaPaint
'
theView = av.GetActiveDoc
p2 = theView.GetDisplay.ReturnUserPoint
x1 = _p1.GetX
y1 = _p1.GetY
x2 = p2.GetX
y2 = p2.GetY
for each i in 0..0
if ((x1=x2)and(y1<y2))
then
_angle = 0
break
end
if ((x1=x2)and(y1>y2))
then
_angle = 180
break
end
if ((y1=y2)and(x1<x2))
then
_angle = 90
break
end
if ((y1=y2)and(x1>x2))
then
_angle = 270
break
end
if ((x1<x2)and(y1<y2)) then
_angle =
(((x1-x2).Abs)/((y1-y2).Abs)).atan.AsDegrees
end
if ((x1<x2)and(y1>y2)) then
_angle =
(((y1-y2).Abs)/((x1-x2).Abs)).atan.AsDegrees + 90
end
if ((x1>x2)and(y1>y2)) then
_angle =
(((x1-x2).Abs)/((y1-y2).Abs)).atan.Asdegrees + 180
end
if ((x1>x2)and(y1<y2)) then
_angle =
(((y1-y2).Abs)/((x1-x2).Abs)).atan.asDegrees +270
end
end
av.ShowMsg(_angle.SetFormat("d.dd").AsString ++ "degrees")
System.RefreshWindows
av.Run("aaTimer",nil)
'
'End of Script: aaPaint

Code:
'Script: aaTimer.ave
'
if (av.getactivedoc.AsString = "View1")
then
av.DelayedRun("aaPaint", nil, 0.5)
end
'
'End of Script: aaTimer.ave