Select to view content in your preferred language

Help with hatch text expression for mileage

1266
4
Jump to solution
06-20-2012 01:35 AM
MarcSommer
Deactivated User
Hello,

I´m working with ArcGIS v10. I would like to have a route with hatch text expressions like this: 50+500 km.
Creating a route and displaying the "standard" milage e.g. for a river like "20,5" is done, but I don´t know the right Phyton-code to label the hatches like written above.

I startet trying with this:

Function FindLabel ( esri__measure )
  FindLabel = esri__measure/1000
End Function

The results is a milage in km, but I don´t know to ad a "+" and every half kilometer a "500" or a "0".

Thanks for any help!

Marc
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MarcinGasior
Frequent Contributor
Actually, I didn't choose any parser.
The syntax is VBScript, but when I select VBScript parser it doesn't work indeed. (It seem that esri__measure works only when no parser is selected)

To unselect parser unclick 'Advanced' and click it again.

One more note to this script: it works in this form if esri__measure is in meter and hatch interval is 500 m.

View solution in original post

0 Kudos
4 Replies
MarcinGasior
Frequent Contributor
If I infered correctly, your esri__measure is in meters.
If so the following code produces results as below:
Function FindLabel ( esri__measure )
  If Right(CStr(esri__measure), 3) = "500" Then
     FindLabel = CStr((esri__measure-500)/1000) & " + " & "500 km"
  Else
     FindLabel = CStr((esri__measure)/1000) & " + " & "0 km"
  End If
End Function

[ATTACH=CONFIG]15340[/ATTACH]    [ATTACH=CONFIG]15341[/ATTACH]
0 Kudos
MarcSommer
Deactivated User
Hi,

looks great! It´s written in VBA right? If I paste it in ArcGIS it says, that the code cointains a mistake.
I took the VBScript parser. Check the pic below (hope you understand it´s german version).

[ATTACH=CONFIG]15342[/ATTACH]

Marc
0 Kudos
MarcinGasior
Frequent Contributor
Actually, I didn't choose any parser.
The syntax is VBScript, but when I select VBScript parser it doesn't work indeed. (It seem that esri__measure works only when no parser is selected)

To unselect parser unclick 'Advanced' and click it again.

One more note to this script: it works in this form if esri__measure is in meter and hatch interval is 500 m.
0 Kudos
MarcSommer
Deactivated User
Great! Thx a lot!
0 Kudos