Solved! Go to Solution.
To get to the hatching you have to be using a route. The esri__measure comes from that automatically and is not a field that requires the [].
To get to the hatch just go to your route properties and it will be a tab at the top. Under the Hatch Class in the box on the left there will be a Hatch Def(1) or however many you add. If you click on the Hatch Def you will have options, one of which will be to label the hatches you have set up. You can control the symbol here like normal. You can then click the label settings in the label section and click the build a text expression bubble and then click the expression button.
Once you click the expression button the dialogue box looks the exactly the same except it says Hatch Text Expression at the top instead of Label Expression. This is why I assume they are the same, just in two different places.
I appreciate the help with this,
Thanks
def FindLabel ( esri__measure ): if len(str(int( esri__measure ))) == 0: return "0+00" elif len(str(int( esri__measure ))) == 2: return "0+{0}{1}".format( *esri__measure ) elif len(str(int( esri__measure ))) == 3: return "{0}+{1}{2}".format( *esri__measure ) elif len(str(int( esri__measure ))) == 4: return "{0}{1}+{2}{3}".format( *esri__measure ) elif len(str(int( esri__measure))) == 5: return "{0}{1}{2}+{3}{4}".format( *esri__measure ) elif len(str(int( esri__measure ))) == 6: return "{0}{1}{2}{3}+{4}{5}".format( *esri__measure )
It verifies, but it returns nothing. Just a blank. I also tried it without the str(int part and got the same thing. A blank when verified.
def FindLabel (esri__measure): EM = str(int(round(esri__measure))) if len(EM) == 0: return "0+00" elif len(EM) == 1: return "0+0{0}".format(*EM) elif len(EM) == 2: return "0+{0}{1}".format(*EM) elif len(EM) == 3: return "{0}+{1}{2}".format(*EM) elif len(EM) == 4: return "{0}{1}+{2}{3}".format(*EM) elif len(EM) == 5: return "{0}{1}{2}+{3}{4}".format(*EM) elif len(EM) == 6: return "{0}{1}{2}{3}+{4}{5}".format(*EM)
The code block, which is simply a python function that takes an input and returns an output, should use a Python variable -- not field names. (The insertion of the field value for [fieldname] only happens in the expression block.)Expression: FindLabel(![FIELDNAME]!) Code: def FindLabel(fn): rs = fn[:3] # first three chars ls = fn[3:] # characters four-> end return "{0}+{1}".format(rs, ls)
Thank you StacyRendall!!!!
I was almost there, not sure what happened to the == 1 in that one block, I swear it was there before.
So the trick is to make the variable and do the rounding and integer business then get the length of that instead of trying to do it on every if statement, saving all that typing in the process haha.
I'm still pretty new to python, only on chapter 7 in my book and that was the first time using the .format and * so thanks for teaching me something new. I'll get it all figured out eventually.
Thanks again!
Now I just have to figure out how to get them perpendicular to my line.
Oh, that worked if someone missed it.