<?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: Attempting to use showLabels script within a model... in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/attempting-to-use-showlabels-script-within-a-model/m-p/354949#M27922</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you want to see the result of scripts run in the Python Window in ArcMap reflected in the current map, reference the map document like this:&lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt;mxd = arcpy.mapping.MapDocument('current')&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That should do what you want.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 Feb 2013 21:45:43 GMT</pubDate>
    <dc:creator>JeffMoulds</dc:creator>
    <dc:date>2013-02-19T21:45:43Z</dc:date>
    <item>
      <title>Attempting to use showLabels script within a model...</title>
      <link>https://community.esri.com/t5/python-questions/attempting-to-use-showlabels-script-within-a-model/m-p/354948#M27921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm attempting to use a small script within my mxd (will later attach to a model) that will turn the labels on for a layer. My code is essentially straight from the Resource Center:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy mxd = arcpy.mapping.MapDocument(r"C:\path\to\my.mxd") for lyr in arcpy.mapping.ListLayers(mxd): &amp;nbsp; if lyr.description == "Layer Name": &amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.showLabels = True del mxd arcpy.RefreshTOC() arcpy.RefreshActiveView()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am running it with the mxd open from the python window. It looks like it is working because the map does refresh but the labels are not turning on.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Feb 2013 17:25:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/attempting-to-use-showlabels-script-within-a-model/m-p/354948#M27921</guid>
      <dc:creator>CraigMcDade</dc:creator>
      <dc:date>2013-02-19T17:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: Attempting to use showLabels script within a model...</title>
      <link>https://community.esri.com/t5/python-questions/attempting-to-use-showlabels-script-within-a-model/m-p/354949#M27922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you want to see the result of scripts run in the Python Window in ArcMap reflected in the current map, reference the map document like this:&lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt;mxd = arcpy.mapping.MapDocument('current')&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That should do what you want.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Feb 2013 21:45:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/attempting-to-use-showlabels-script-within-a-model/m-p/354949#M27922</guid>
      <dc:creator>JeffMoulds</dc:creator>
      <dc:date>2013-02-19T21:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: Attempting to use showLabels script within a model...</title>
      <link>https://community.esri.com/t5/python-questions/attempting-to-use-showlabels-script-within-a-model/m-p/354950#M27923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If you want to see the result of scripts run in the Python Window in ArcMap reflected in the current map, reference the map document like this:&lt;PRE class="lia-code-sample line-numbers language-none"&gt;mxd = arcpy.mapping.MapDocument('current')&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;That should do what you want.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks. Helped point me in the right direction.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I wound up with:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
... mxd = arcpy.mapping.MapDocument("CURRENT") 
... layer = arcpy.mapping.ListLayers(mxd, "")[0] 
... if layer.supports("LABELCLASSES"):
...&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; lblclass.showClassLabels = True
... lblclass.expression = " [PARCELID]"
... layer.showLabels = True
... arcpy.RefreshActiveView()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:38:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/attempting-to-use-showlabels-script-within-a-model/m-p/354950#M27923</guid>
      <dc:creator>CraigMcDade</dc:creator>
      <dc:date>2021-12-11T16:38:25Z</dc:date>
    </item>
  </channel>
</rss>

