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]"
BritishSteel
6,7174 gold badges41 silver badges66 bronze badges
asked Oct 19, 2011 at 19:19
6
  • Does it work if you manually write the CRLF control characters \r\n at the desired line breaks in the expression string? Commented Oct 19, 2011 at 21:29
  • or just try like [SUPP_NO] & \n [Fuse_Count] Commented 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. Commented 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. Commented 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. Commented 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
answered Jan 28, 2014 at 21:20
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. Commented Feb 21, 2014 at 12:50
-1
Function FindLabel ( [No], [Instructio] , [Y], [X] )
 FindLabel = [No] &vbnewline & " " & [Instructio] &vbnewline & "Y " & [Y] & " X " & [X] 
End Function
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
answered Feb 17, 2015 at 9:18

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.