OK, I finally found the Hatch Expression calculator. Previously I was testing on Label Expression/Display expression, assuming that they were the same thing. They are not. If it is any use to others: more information is shown below about locating the Hatch Expression tool and the testing that lead to finding the answer.In Hatch Expression, this seems to work (note that it is not advanced, so that box must be un-checked):"{0}{1}{2}+{3}{4}".format( *str(esri__measure))
As before, this will only work for inputs of length 5. If you want to condition test, this seems to work (is advanced, box must be checked):def FindLabel ( esri__measure):
EM = str(esri__measure)
if len(EM) == 5:
return "{0}{1}{2}+{3}{4}".format(*EM)
elif len(EM) == 6:
return "{0}{1}{2}{3}+{4}{5}".format(*EM)
else:
return "UNDEFINED INPUT"
Unfortunately it doesn't seem possible to have any square brackets anywhere within the statement (see below). If this was possible, something like the following would work for any length of input > 2:def FindLabel (esri__measure):
s = ''.join(['{%s}' % i for i in str(esri__measure)])
return s[:-6] + '+' + s[-6:]
[/HR]For others reading this post: Hatch Expression is (only? - I can't find much info) a property of Network Analyst Routes. To find Hatch Expression: Solve an NA Route analysis, use Layer Properties on the Route, select Hatches tab, go to the Hatch Def, under labels tick Label these hatches, click Label Settings, select Build a text expression radio button, click the Expression button... Here is an image showing the steps, and initial state after setting to Python and checking the advanced option:[ATTACH=CONFIG]26685[/ATTACH]Things that work (display an output after clicking Verify):[INDENT]Non-advanced (i.e. single line):esri__measure
str(esri__measure)
'{0}'.format(esri__measure)
[/INDENT][INDENT]Advanced:def FindLabel ( esri__measure):
return esri__measure
def FindLabel ( esri__measure):
return str(esri__measure)
def FindLabel ( esri__measure):
EM = str(esri__measure)
return EM
[/INDENT]Things that fail (display No features found. Could not verify expression. after clicking Verify):[INDENT]Non-advanced:str(esri__measure)[0]
[/INDENT][INDENT]Advanced:def FindLabel ( esri__measure):
EM = str(esri__measure)
return EM[0] + EM[-1]
[/INDENT]