3

I am able to set simple label expressions, but when I try to set multiline expressions (which all VBScript expressions are) it does not get copied into the expression box properly. I have tried using Python's triple quote technique for multilines but that only seperates each line with a tab in the expression window. Anyone know of a way to do this? If so, does the label class need to be set to 'advanced' first, or is it possible to automate this aspect as well?

Alternatively, loading in precreated expression files would work just as well if not better if this is possible to script.

This is with the use of the Maplex extension.

EDIT

Basically this code below needs to be pasted into the expression box with Arcpy. One line works just fine, but because there are multiple lines, I can't get it to paste it properly.

Function FindLabel ( [SUPP_NO], [SUPP_SUFF])
IF [SUPP_SUFF] = "000" THEN 
FindLabel = "#" & [SUPP_NO] & VBNewLine & [Fuse_Count]"
6
  • Does it work if you manually write the CRLF control characters \r\n at the desired line breaks in the expression string?
    – blah238
    Oct 19, 2011 at 21:29
  • or just try like [SUPP_NO] & \n [Fuse_Count]
    – Brad Nesom
    Oct 20, 2011 at 3:02
  • @blah238 Yes that combination does work! In fact all that was needed was the \r. However I am finding that there is no way to set the expression type to advanced from within Arcpy. This is unfortunate, and means that what I want to do doesn't appear to be possible. I also don't see a way to set new label classes from within Arcpy. Seems like they have to be predefined.
    – amasephy
    Oct 20, 2011 at 13:09
  • Does it work correctly even if the "advanced" checkbox is not checked? I doubt that it has any effect other than graphical.
    – blah238
    Oct 22, 2011 at 0:06
  • @blah238 Unfortunately it does make a difference. The box needs to be checked otherwise arcmap does not allow functions in the expression.
    – amasephy
    Oct 22, 2011 at 1:52

2 Answers 2

1

You need to add an EndIf to your function and you must have the [Fuse_Count] in your first line. Give this a try:

Function FindLabel ( [SUPP_NO], [SUPP_SUFF], [FUSE_COUNT] )
   if [SUPP_SUFF] = "000" then
       FindLabel = "#" & [SUPP_NO] & vbnewline & [FUSE_COUNT]
   end if
End Function
1
  • I just posted a snippet above. I confirmed with ESRI support that there is no way to enable the 'Advanced' tick box from Arcpy. Since this can not be enabled in code, advanced expressions can't be entered from Arcpy.
    – amasephy
    Feb 21, 2014 at 12:50
-1
Function FindLabel ( [No], [Instructio] , [Y], [X] )
  FindLabel = [No] &vbnewline & " " &  [Instructio] &vbnewline &  "Y   "  &  [Y] & "  X  " & [X] 
End Function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.