<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: applying label expressions, a clunky work around in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/applying-label-expressions-a-clunky-work-around/m-p/583765#M45786</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;When the {symbology_only} property on UpdateLayer is set to False, it pulls across ALL layer properties, not just symbology.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have you tried working with the LabelClass object.&amp;nbsp; It allows you to set the expression directly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/LabelClass/00s30000002t000000/"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/LabelClass/00s30000002t000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Oct 2011 12:56:23 GMT</pubDate>
    <dc:creator>JeffBarrette</dc:creator>
    <dc:date>2011-10-12T12:56:23Z</dc:date>
    <item>
      <title>applying label expressions, a clunky work around</title>
      <link>https://community.esri.com/t5/python-questions/applying-label-expressions-a-clunky-work-around/m-p/583764#M45785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;is there a better way to apply a label exprssion to a layer in arcmap besides the workaround posted below? there is a layer in arcmap that needs to be symbolized and labeled in the same manner as a layer file and doing an updateLayer TRUE won't do it, so the updateLayer is used with FALSE &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;then the source and name of the layer gets reset&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the layer file was created from a template of the edit feature class in the MXD so that all fields and spatial attributes match&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;#### Description: Changes the symbology and labels fot the footprint layer

## Import standard modules
import sys, os

## Set the necessary product code
import arcinfo

## Import arcpy module and environment module
import arcpy
import arcpy.mapping
from arcpy import env

## Get the selection layer
SetLayer = arcpy.GetParameterAsText(0)


## Sets the MXD file
IMXD = arcpy.mapping.MapDocument("CURRENT")

## Sets the Dataframe
DF = arcpy.mapping.ListDataFrames(IMXD, "Layers")[0]

## Set a Layer
ILayer = arcpy.mapping.ListLayers(IMXD, SetLayer, DF)[0]


SymbolLayer = arcpy.mapping.Layer(r"C:\WorkSpace\Bldg_Footprints\HollowFootprints.lyr")

KeepName = ILayer.name
KeepDataset = ILayer.datasetName
KeepSource = ILayer.workspacePath

arcpy.mapping.UpdateLayer(DF, ILayer, SymbolLayer, False)

ILayer = arcpy.mapping.ListLayers(IMXD, "Footprints_Layer", DF)[0]

ILayer.replaceDataSource(KeepSource, "FILEGDB_WORKSPACE", KeepDataset)
ILayer.name = KeepName


arcpy.RefreshTOC()
arcpy.RefreshActiveView()
del IMXD, ILayer&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 14:25:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/applying-label-expressions-a-clunky-work-around/m-p/583764#M45785</guid>
      <dc:creator>FrankVignati</dc:creator>
      <dc:date>2011-10-11T14:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: applying label expressions, a clunky work around</title>
      <link>https://community.esri.com/t5/python-questions/applying-label-expressions-a-clunky-work-around/m-p/583765#M45786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;When the {symbology_only} property on UpdateLayer is set to False, it pulls across ALL layer properties, not just symbology.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have you tried working with the LabelClass object.&amp;nbsp; It allows you to set the expression directly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/LabelClass/00s30000002t000000/"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/LabelClass/00s30000002t000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Oct 2011 12:56:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/applying-label-expressions-a-clunky-work-around/m-p/583765#M45786</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2011-10-12T12:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: applying label expressions, a clunky work around</title>
      <link>https://community.esri.com/t5/python-questions/applying-label-expressions-a-clunky-work-around/m-p/583766#M45787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;thank you, the LabelClass object does allow me to get close to setting the label for a layer as opposed to the work around&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;however there is still a problem&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the layer when originaly added to the MXD is labeling on a single attribute by default and when the following script is run the label expression is not valid since the label expression is not set to advaced, is there a way to set the expression to advanced through arcpy?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;this is the script that attempts to set the expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;## Import standard modules
import sys, os
## Set the necessary product code
import arcinfo
## Import arcpy module and environment module
import arcpy
import arcpy.mapping
from arcpy import env

## Overwrite pre-existing files
arcpy.env.overwriteOutput = True
## Sets the MXD file
IMXD = arcpy.mapping.MapDocument("CURRENT")
## Sets the Dataframe
DF = arcpy.mapping.ListDataFrames(IMXD, "Layers")[0]
## Set a Layer
ILayer = arcpy.mapping.ListLayers(IMXD, "Footprints_0592", DF)[0]

NewX = "Function FindLabel ( [BLDG_CODE] , [ALTKEY]&amp;nbsp; )" + "\n" + "If&amp;nbsp; [BLDG_CODE] &amp;lt;&amp;gt; \"Base Residential Area (BAS)\" Then" + "\n" + "&amp;nbsp; FindLabel = [BLDG_CODE]" + "\n" + "Else" + "\n" + "&amp;nbsp; FindLabel =&amp;nbsp; [ALTKEY] &amp;amp;&amp;nbsp; vbCrLf &amp;amp; [BLDG_CODE]" + "\n" + "End If" + "\n" + "End Function"

for Label in ILayer.labelClasses:
&amp;nbsp; Label.expression = NewX&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the NewX variable comes out like and if the expression is saved it stays this way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Function FindLabel ( [BLDG_CODE] , [ALTKEY]&amp;nbsp; )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If&amp;nbsp; [BLDG_CODE] &amp;lt;&amp;gt; "Base Residential Area (BAS)" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; FindLabel = [BLDG_CODE]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Else&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; FindLabel =&amp;nbsp; [ALTKEY] &amp;amp;&amp;nbsp; vbCrLf &amp;amp; [BLDG_CODE]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;End If&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;End Function&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but in the properties for the layer the expression is still set to simple so it will not work&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:06:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/applying-label-expressions-a-clunky-work-around/m-p/583766#M45787</guid>
      <dc:creator>FrankVignati</dc:creator>
      <dc:date>2021-12-12T01:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: applying label expressions, a clunky work around</title>
      <link>https://community.esri.com/t5/python-questions/applying-label-expressions-a-clunky-work-around/m-p/583767#M45788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No there is not.&amp;nbsp; This is a property that would need to be authored in the map document or a layer file ahead of time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If that is not possible, we'd like to learn more about your scenario for possible consideration to future releases.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2011 13:10:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/applying-label-expressions-a-clunky-work-around/m-p/583767#M45788</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2011-10-14T13:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: applying label expressions, a clunky work around</title>
      <link>https://community.esri.com/t5/python-questions/applying-label-expressions-a-clunky-work-around/m-p/583768#M45789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;No there is not.&amp;nbsp; This is a property that would need to be authored in the map document or a layer file ahead of time.&lt;BR /&gt;&lt;BR /&gt;If that is not possible, we'd like to learn more about your scenario for possible consideration to future releases.&lt;BR /&gt;&lt;BR /&gt;Jeff&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;what is happening is a python script runs creating feature classes from dxf files and adds them to mxds as layers to be edited and the layers are symbolized and labeled in a manner to make it easier for the editors to save time the script does it all and the editor need only open the mxd with the data already to go&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;besides for purposes like above, it would be helpful for automating output if the "Advanced" on the label could be set through arcpy for folks adding layers and making maps&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Oct 2011 11:54:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/applying-label-expressions-a-clunky-work-around/m-p/583768#M45789</guid>
      <dc:creator>FrankVignati</dc:creator>
      <dc:date>2011-10-17T11:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: applying label expressions, a clunky work around</title>
      <link>https://community.esri.com/t5/python-questions/applying-label-expressions-a-clunky-work-around/m-p/583769#M45790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am running into this exact problem.&amp;nbsp; I've made a post on Esri's Idea page requesting this functionality as well as exposing all of the settings in the label manager through ArcPy.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://ideas.arcgis.com/ideaView?id=08730000000bsHbAAI"&gt;http://ideas.arcgis.com/ideaView?id=08730000000bsHbAAI&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Oct 2011 14:13:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/applying-label-expressions-a-clunky-work-around/m-p/583769#M45790</guid>
      <dc:creator>JohnHayes2</dc:creator>
      <dc:date>2011-10-20T14:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: applying label expressions, a clunky work around</title>
      <link>https://community.esri.com/t5/python-questions/applying-label-expressions-a-clunky-work-around/m-p/583770#M45791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for posting this to the ideas page.&amp;nbsp; We'll take this into consideration for our next release.&amp;nbsp; Note it is too late for the 10.1 timeframe.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Oct 2011 19:34:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/applying-label-expressions-a-clunky-work-around/m-p/583770#M45791</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2011-10-24T19:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: applying label expressions, a clunky work around</title>
      <link>https://community.esri.com/t5/python-questions/applying-label-expressions-a-clunky-work-around/m-p/583771#M45792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Frank,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is the schema of the output shapefiles similar each time? If so it seems like you could author the layer files for the shapefiles once and in the script update the datasource of the layer through code and add it to the map document.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Oct 2011 23:11:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/applying-label-expressions-a-clunky-work-around/m-p/583771#M45792</guid>
      <dc:creator>ChrisFox3</dc:creator>
      <dc:date>2011-10-24T23:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: applying label expressions, a clunky work around</title>
      <link>https://community.esri.com/t5/python-questions/applying-label-expressions-a-clunky-work-around/m-p/583772#M45793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Has anyone come up with a solution to this?&amp;nbsp; I just completed a 10 page script and this function is the only thing I need to complete my tool.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Dec 2011 11:49:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/applying-label-expressions-a-clunky-work-around/m-p/583772#M45793</guid>
      <dc:creator>deleted-user-MS0lE1F_0-sy</dc:creator>
      <dc:date>2011-12-21T11:49:29Z</dc:date>
    </item>
  </channel>
</rss>

