Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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]"
share|improve this question
    
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 '11 at 21:29
    
or just try like [SUPP_NO] & \n [Fuse_Count] –  Brad Nesom Oct 20 '11 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 '11 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 '11 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 '11 at 1:52

1 Answer 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
share|improve this answer
    
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 at 12:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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