HOW TO
The measure tool only measures polylines on a plane. You can measure a polyline in three dimensions with the script provided in this document. You must have the Spatial or 3D Analyst extension loaded in order for this operation to work properly.
Code:
'-- This script uses an active grid theme and a polyline graphic in your view.
'-- It calculates the 3-dimensional distance of that polyline using the values of
'-- the grid cells as a base.
theView = av.getactivedoc
if (theView.Is(View).Not)
then
MsgBox.Info
("The active window must be the View",
"Please try again")
exit
end
theDisplay = theView.GetDisplay
theDistUnits = theDisplay.GetDistanceUnits
theMapUnits = theDisplay.GetUnits
if (theDistUnits <> theMapUnits)
then
MsgBox.Info
("The View's Distance Units and Map Units"+NL+
"must be the same. Go to View Properties"+NL+
"and check it out.","Please try again")
exit
end
theGTheme = theView.GetActiveThemes.Get(0)
if (theGTheme.Is(GTheme).Not)
then
MsgBox.Info
("The active theme must be a GRID theme",
"Please try again")
exit
end
theSelGraphicList = theView.GetGraphics.GetSelected
theNumSelGraphics = theSelGraphicList.Count
if (theNumSelGraphics < 1)
then
MsgBox.Info
("You must first have a graphic selected.",
"Please try again")
exit
end
if (theNumSelGraphics > 1)
then
MsgBox.Info
("You must have only ONE graphic selected.",
"Please try again")
exit
end
thePolyline = theSelGraphicList.Get(0).GetShape
if (thePolyline.Is(Polyline).Not)
then
MsgBox.Info
("The graphic must be a single Polyline.",
"Please try again")
exit
end
thePointList = thePolyline.AsList.get(0)
'-- Initialize the counters
measureCount = (thePointList.Count) - 2
trailLength = 0
birdLength = 0
startMark = 0
endMark = 1
'-- Calculate the distances
theGrid = theGTheme.GetGrid
for each i in 0..measureCount
av.ShowMsg("Calculating Trail Distance...")
av.SetStatus((i/measureCount) * 100)
p1 = thePointList.Get(startMark)
p2 = thePointList.Get(endMark)
v1 = theGrid.CellValue(p1,(Prj.MakeNull))
v2 = theGrid.CellValue(p2,(Prj.MakeNull))
len = p1.distance(p2)
rise = (v1 - v2).Abs
hypo = ((len^2) + (rise^2)).sqrt
trailLength = trailLength + hypo
birdLength = birdLength + len
startMark = startMark + 1
endMark = endMark + 1
end
'-- Display the results
birdLength = birdLength.SetFormat("d.d").AsString
trailLength = trailLength.SetFormat("d.d").AsString
av.ClearMsg
av.ClearStatus
if (theDistUnits = #UNITS_LINEAR_FEET)
then theUnits = " feet."
elseif (theDistUnits = #UNITS_LINEAR_METERS)
then theUnits = " meters."
else theUnits = " map units."
end
MsgBox.Info("This is the distance of your trail:"
+NL++NL+"2-dim distance:"++birdLength+theUnits+NL+
"3-dim distance:"++trailLength+theUnits,
"As the crow flies vs. As the person walks")
Article ID:000005197
Get help from ArcGIS experts
Download the Esri Support App