<?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: ArcPy: Using lblclass expression to change font style and color in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-using-lblclass-expression-to-change-font/m-p/26743#M2022</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Very nice!&amp;nbsp; Glad it works now, neat trick.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 12 Oct 2012 13:33:44 GMT</pubDate>
    <dc:creator>T__WayneWhitley</dc:creator>
    <dc:date>2012-10-12T13:33:44Z</dc:date>
    <item>
      <title>ArcPy: Using lblclass expression to change font style and color</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-using-lblclass-expression-to-change-font/m-p/26739#M2018</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I´m trying to label features of a dataset using ArcPy and the &lt;/SPAN&gt;&lt;STRONG&gt;lblclass function&lt;/STRONG&gt;&lt;SPAN&gt;. While commands like "VBNewline" and "Round" work pretty well, I´m not able to change colors or font style. An expression that works in ArcMap doesn´t work in the script. Could anyone help me out please? I´m using ArcGIS 10.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code that works:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;#Adding Labels &amp;nbsp;&amp;nbsp;&amp;nbsp; layer = arcpy.mapping.ListLayers(mxd, "")[0]&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if layer.supports("LABELCLASSES"): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for lblclass in layer.labelClasses: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lblclass.className = "Flaeche" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lblclass.expression = "[FID] &amp;amp; VBNewLine &amp;amp; Round([AREA_mm2],2)" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lblclass.showClassLabels = True &amp;nbsp;&amp;nbsp;&amp;nbsp; layer.showLabels = True &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshActiveView() &lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Code that works in ArcMap but not in ArcPy:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;#Adding Labels layer = arcpy.mapping.ListLayers(mxd, "")[0]&amp;nbsp; if layer.supports("LABELCLASSES"): &amp;nbsp;&amp;nbsp;&amp;nbsp; for lblclass in layer.labelClasses: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lblclass.className = "Flaeche" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lblclass.expression = ""&amp;lt;CLR red='255' green='0' blue='0'&amp;gt;" &amp;amp; [FID] &amp;amp; VBNewLine &amp;amp; Round([AREA_mm2],2) &amp;amp; "&amp;lt;/CLR&amp;gt;"" &amp;nbsp;&amp;nbsp;&amp;nbsp; lblclass.showClassLabels = True layer.showLabels = True arcpy.RefreshActiveView()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Oct 2012 10:05:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-using-lblclass-expression-to-change-font/m-p/26739#M2018</guid>
      <dc:creator>MartinScheiber</dc:creator>
      <dc:date>2012-10-12T10:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy: Using lblclass expression to change font style and color</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-using-lblclass-expression-to-change-font/m-p/26740#M2019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Text formatting tags are not interpreted by Python, VBScript, and JScript.....end up passed as plain text to ArcMap and 'dynamically' interpreted.&amp;nbsp; I paraphrased from here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//00s80000000p000000"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//00s80000000p000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So then, how to handle?&amp;nbsp;&amp;nbsp; Test this, but I think it'll work if you take out the internal double quotes...with the extra quotes in the exp, I think ArcMap isn't 'aware' of the tags.&amp;nbsp; And with one set of double quotes to set the text string to pass lblclass to in turn pass to the label engine, it'll work I think...see this too:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//00s800000027000000"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//00s800000027000000&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Oct 2012 11:26:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-using-lblclass-expression-to-change-font/m-p/26740#M2019</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2012-10-12T11:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy: Using lblclass expression to change font style and color</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-using-lblclass-expression-to-change-font/m-p/26741#M2020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;EDIT:&amp;nbsp; Actually, I think I got it backwards and there's another error too... Remove the outer quotes, and use '+' not '&amp;amp;' to concatenate strings, and convert all 'parts' to string.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Oct 2012 11:53:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-using-lblclass-expression-to-change-font/m-p/26741#M2020</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2012-10-12T11:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy: Using lblclass expression to change font style and color</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-using-lblclass-expression-to-change-font/m-p/26742#M2021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Dear Wayne,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for your answers!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I got the following tip in a different GIS forum and with this it works perfectly now !&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;This code doesn't work because Python interpreter doesn't understand two double quotes in a row.&lt;BR /&gt;Instead you can try this:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;lblclass.expression = '"%s" &amp;amp; [FID] &amp;amp; VBNewLine &amp;amp; Round([AREA_mm2],2) &amp;amp; "%s"' % ("&amp;lt;CLR red='255' green='0' blue='0'&amp;gt;", "&amp;lt;/CLR&amp;gt;")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Oct 2012 12:03:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-using-lblclass-expression-to-change-font/m-p/26742#M2021</guid>
      <dc:creator>MartinScheiber</dc:creator>
      <dc:date>2012-10-12T12:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy: Using lblclass expression to change font style and color</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-using-lblclass-expression-to-change-font/m-p/26743#M2022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Very nice!&amp;nbsp; Glad it works now, neat trick.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Oct 2012 13:33:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-using-lblclass-expression-to-change-font/m-p/26743#M2022</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2012-10-12T13:33:44Z</dc:date>
    </item>
  </channel>
</rss>

