<?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: Apply Symbology to TOC layers in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/apply-symbology-to-toc-layers/m-p/489692#M38304</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you see &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/apply-symbology-from-layer.htm"&gt;&lt;STRONG&gt;Apply Symbology from Laye&lt;/STRONG&gt;&lt;/A&gt;r there is a code sample at the end.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 27 Jan 2018 01:05:07 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2018-01-27T01:05:07Z</dc:date>
    <item>
      <title>Apply Symbology to TOC layers</title>
      <link>https://community.esri.com/t5/python-questions/apply-symbology-to-toc-layers/m-p/489691#M38303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a .lyr file on my desktop that I would like apply symbology to a TOC sde layer in an existing map document. How can I do this using python IDLE?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Jan 2018 00:46:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/apply-symbology-to-toc-layers/m-p/489691#M38303</guid>
      <dc:creator>JordanMiller5</dc:creator>
      <dc:date>2018-01-27T00:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: Apply Symbology to TOC layers</title>
      <link>https://community.esri.com/t5/python-questions/apply-symbology-to-toc-layers/m-p/489692#M38304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you see &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/apply-symbology-from-layer.htm"&gt;&lt;STRONG&gt;Apply Symbology from Laye&lt;/STRONG&gt;&lt;/A&gt;r there is a code sample at the end.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Jan 2018 01:05:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/apply-symbology-to-toc-layers/m-p/489692#M38304</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-01-27T01:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: Apply Symbology to TOC layers</title>
      <link>https://community.esri.com/t5/python-questions/apply-symbology-to-toc-layers/m-p/489693#M38305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did try using the example code but it didn't work. I'll post my code and error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: If I run the symbology to TOC part of the script inside the map python it works great. Why is it not able to run outside in IDLE?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Name: Create Map&lt;/P&gt;&lt;P&gt;# Import system modules&lt;BR /&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;/P&gt;&lt;P&gt;# Rebuild Map Workspace&lt;BR /&gt;#&lt;BR /&gt;mxd = arcpy.mapping.MapDocument(r"C:\Users\aa2zz6\Desktop\test\Untitled.mxd")&lt;/P&gt;&lt;P&gt;df = arcpy.mapping.ListDataFrames(mxd, "*")[0]&lt;BR /&gt;# Add layer to TOC&lt;BR /&gt;#&lt;BR /&gt;addLayer = arcpy.mapping.Layer(r"I:\UPDM.gdb\P_PipeSystem\P_Meters")&lt;BR /&gt;arcpy.mapping.AddLayer(df, addLayer, "BOTTOM")&lt;/P&gt;&lt;P&gt;addLayer = arcpy.mapping.Layer(r"I:\UPDM.gdb\P_PipeSystem\P_MeterSetting")&lt;BR /&gt;arcpy.mapping.AddLayer(df, addLayer, "BOTTOM")&lt;/P&gt;&lt;P&gt;addLayer = arcpy.mapping.Layer(r"I:\UPDM.gdb\P_PipeSystem\P_Regulator")&lt;BR /&gt;arcpy.mapping.AddLayer(df, addLayer, "BOTTOM")&lt;/P&gt;&lt;P&gt;addLayer = arcpy.mapping.Layer(r"I:\UPDM.gdb\P_PipeSystem\P_TownBorderStation")&lt;BR /&gt;arcpy.mapping.AddLayer(df, addLayer, "BOTTOM")&lt;/P&gt;&lt;P&gt;mxd.save()&lt;/P&gt;&lt;P&gt;# Apply Symbology to TOC layer&lt;/P&gt;&lt;P&gt;#Set layer to apply symbology to&lt;BR /&gt;lyr = "P_Meters"&lt;/P&gt;&lt;P&gt;# Set layer that output symbology will be based on&lt;BR /&gt;ymbolLyr = r"C:\Users\aa2zz6\Desktop\test\Meters.lyr"&lt;/P&gt;&lt;P&gt;# Apply the symbology from the symbology layer to the input layer&lt;BR /&gt;arcpy.ApplySymbologyFromLayer_management(lyr, symbolLyr)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Error&lt;/P&gt;&lt;P&gt;Traceback (most recent call last): File "C:\Users\aa2zz6\Downloads\CREATE NEW MXD.py", line 38, in arcpy.ApplySymbologyFromLayer_management(lyr, symbolLyr) NameError: name 'symbolLyr' is not defined&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Jan 2018 04:12:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/apply-symbology-to-toc-layers/m-p/489693#M38305</guid>
      <dc:creator>JordanMiller5</dc:creator>
      <dc:date>2018-01-27T04:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Apply Symbology to TOC layers</title>
      <link>https://community.esri.com/t5/python-questions/apply-symbology-to-toc-layers/m-p/489694#M38306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jordan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In following line of script "symbolLyr"&amp;nbsp; is defined as "ymbolLyr", as stated in error trace back.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Set layer that output symbology will be based on&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ymbolLyr&lt;/STRONG&gt; = r"C:\Users\aa2zz6\Desktop\test\Meters.lyr"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Jan 2018 05:33:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/apply-symbology-to-toc-layers/m-p/489694#M38306</guid>
      <dc:creator>Madanbhurati</dc:creator>
      <dc:date>2018-01-27T05:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Apply Symbology to TOC layers</title>
      <link>https://community.esri.com/t5/python-questions/apply-symbology-to-toc-layers/m-p/489695#M38307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks like you are on the right track.&amp;nbsp; You can use&amp;nbsp;ApplySymbology outside with IDLE; what type of&amp;nbsp;error do you get when using IDLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a script that I use to apply symbology using a layer file:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; os
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy &lt;SPAN class="comment token"&gt;# if outside ArcMap&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# inside ArcMap, use "CURRENT" for document name&lt;/SPAN&gt;
mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"C:\Path\To\SymbolTest.mxd"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# layer file is in directory with mxd map document; this will be the workspace&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;dirname&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;filePath&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# dictonary matches map layer with symbology layer file&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# layer name in TOC : name of layer file (can use full path/file name if not in map directory)&lt;/SPAN&gt;
symbols &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'SymbolTest'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'LayerSymbology.lyr'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; layer &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; symbols&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Layer: '{}' - previous symbology type: '{}'."&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;symbologyType&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;&lt;SPAN&gt;# &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fdesktop.arcgis.com%2Fen%2Farcmap%2Flatest%2Ftools%2Fdata-management-toolbox%2Fapply-symbology-from-layer.htm" target="_blank"&gt;http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/apply-symbology-from-layer.htm&lt;/A&gt;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;# ApplySymbologyFromLayer_management (in_layer, in_symbology_layer)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Applying symbology to layer '{}' using '{}'."&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; symbols&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ApplySymbologyFromLayer_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; symbols&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Layer: '{}' - new symbology type: '{}'."&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;symbologyType&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Layer '{}' not updated."&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# may need to refresh map&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# arcpy.RefreshTOC()&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# arcpy.RefreshActiveView()&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;del&lt;/SPAN&gt; mxd‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:33:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/apply-symbology-to-toc-layers/m-p/489695#M38307</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-11T21:33:12Z</dc:date>
    </item>
  </channel>
</rss>

