Label Expressions are not supported in Runtime Content. I have a MXD with over 50 layers, grouped by utility, i.e electric, gas, water, fiber, etc. Each layer for each utility has a different label expression. Using arcpy can I read the label expression's Function (the parser is VBScript) and write the value of the Function to a field in that feature class I created in a seperate process?
I started with this example (#1) LabelClass—Help | ArcGIS for Desktop
Here is one result of the above sample, can I read the Function into arcpy and write the return value into an existing field?
@
Layer name: TransformerBankTraffic
Class Name: Default
Expression: Function FindLabel ( [Subtype], [DeviceID], [RatedKVA_A], [RatedKVA_B], [RatedKVA_C], [RatedKVA_Spare] )
blnHasText = False
sPrefix = ucase(left([DeviceID] & " ", 3))
if (sPrefix <> "NON") and (sPrefix <> "UNK") and (sPrefix <> " ") then
blnHasText = True
strLabel = [DeviceID]
end if
if ([subtype] = 5) or ([subtype] = 9) or ([subtype] = 7) then
if blnHasText then
strLabel = strLabel & vbcrlf
else
blnHasText = True
end if
if UCASE([RatedKVA_A]) = "25 KVA" then
strLabel = strlabel & "75 KVA-ABC"
else
if UCASE([RatedKVA_A]) = "37.5 KVA" then
strLabel = strlabel & "112.5 KVA-ABC"
else
if UCASE([RatedKVA_A]) = "50 KVA" then
strLabel = strlabel & "150 KVA-ABC"
else
if UCASE([RatedKVA_A]) = "75 KVA" then
strLabel = strlabel & "225 KVA-ABC"
else
if UCASE([RatedKVA_A]) = "100 KVA" then
strLabel = strlabel & "300 KVA-ABC"
else
if UCASE([RatedKVA_A]) = "167 KVA" then
strLabel = strlabel & "500 KVA-ABC"
else
if UCASE([RatedKVA_A]) = "250 KVA" then
strLabel = strlabel & "750 KVA-ABC"
else
if UCASE([RatedKVA_A]) = "333 KVA" then
strLabel = strlabel & "1000 KVA-ABC"
else
if UCASE([RatedKVA_A]) = "500 KVA" then
strLabel = strlabel & "1500 KVA-ABC"
else
if UCASE([RatedKVA_A]) = "667 KVA" then
strLabel = strlabel & "2000 KVA-ABC"
else
if UCASE([RatedKVA_A]) = "833 KVA" then
strLabel = strlabel & "2500 KVA-ABC"
else
if UCASE([RatedKVA_A]) = "1000 KVA" then
strLabel = strlabel & "3000 KVA-ABC"
else
if UCASE([RatedKVA_A]) = "1250 KVA" then
strLabel = strlabel & "3750 KVA-ABC"
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
else
if UCASE([RatedKVA_A]) <> "NONE" then
if blnHasText then
strLabel = strLabel & vbcrlf
else
blnHasText = True
end if
strLabel = strlabel & [RatedKVA_A] & "-A"
end if
if UCASE([RatedKVA_B]) <> "NONE" then
if blnHasText then
strLabel = strLabel & vbcrlf
else
blnHasText = True
end if
strLabel = strLabel & [RatedKVA_B] & "-B"
end if
if UCASE([RatedKVA_C]) <> "NONE" then
if blnHasText then
strLabel = strLabel & vbcrlf
else
blnHasText = True
end if
strLabel = strLabel & [RatedKVA_C] & "-C"
end if
if UCASE([RatedKVA_Spare]) <> "NONE" then
if blnHasText then
strLabel = strLabel & vbcrlf
else
blnHasText = True
end if
strLabel = strLabel & [RatedKVA_Spare] & "-Spare"
end if
end if
FindLabel = strLabel
End Function