<?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: ApplySymbologyFromLayer_management not working on script tool. Works on Python console. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/applysymbologyfromlayer-management-not-working-on/m-p/10077#M880</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is the script tool running in the background? This will not work as background geoprocessing is always in a separate process from ArcMap (where your layer &lt;SPAN style="color: #0000ff; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;"climate_pp_geq1020"&lt;/SPAN&gt; is living). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can force your script to run in the foreground by either&lt;/P&gt;&lt;P&gt;1) Setting the checkbox "always run in foreground"&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;2) Turning off background geoprocessing in Geoprocessing/Options&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Nov 2014 06:08:49 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2014-11-07T06:08:49Z</dc:date>
    <item>
      <title>ApplySymbologyFromLayer_management not working on script tool. Works on Python console.</title>
      <link>https://community.esri.com/t5/python-questions/applysymbologyfromlayer-management-not-working-on/m-p/10076#M879</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey guys,&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;I can't update layer symbology from my script tool. It's working on the Python console, and it's driving me nuts.&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;I've reduced my code to this most basic example that now follows.&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;On Python console:&lt;BR /&gt; ​&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

arcpy.ApplySymbologyFromLayer_management("climate_pp_geq1020", "//VBOXSVR/data/10min/binarySymbology.lyr")

&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt; This WORKS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On script tool:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

import arcpy

 arcpy.ApplySymbologyFromLayer_management("climate_pp_geq1020", "//VBOXSVR/data/10min/binarySymbology.lyr")

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The EXACT SAME THING ("import arcpy" is the only addition) DOES NOT WORK for me when ran from a script tool instead of the console.&lt;/P&gt;&lt;P&gt;I don't receive any error messages either.&lt;/P&gt;&lt;P&gt;The layer I'm trying to alter is a raster one in case it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using ArcGIS 10.1&lt;/P&gt;&lt;P&gt;I've also tried arcpy.mapping.UpdateLayer instead and it also does nothing with no error messages.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd greatly appreciate it if anyone could give me a solution to this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:25:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/applysymbologyfromlayer-management-not-working-on/m-p/10076#M879</guid>
      <dc:creator>MauricioSilveira</dc:creator>
      <dc:date>2021-12-10T20:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: ApplySymbologyFromLayer_management not working on script tool. Works on Python console.</title>
      <link>https://community.esri.com/t5/python-questions/applysymbologyfromlayer-management-not-working-on/m-p/10077#M880</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is the script tool running in the background? This will not work as background geoprocessing is always in a separate process from ArcMap (where your layer &lt;SPAN style="color: #0000ff; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;"climate_pp_geq1020"&lt;/SPAN&gt; is living). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can force your script to run in the foreground by either&lt;/P&gt;&lt;P&gt;1) Setting the checkbox "always run in foreground"&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;2) Turning off background geoprocessing in Geoprocessing/Options&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Nov 2014 06:08:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/applysymbologyfromlayer-management-not-working-on/m-p/10077#M880</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2014-11-07T06:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: ApplySymbologyFromLayer_management not working on script tool. Works on Python console.</title>
      <link>https://community.esri.com/t5/python-questions/applysymbologyfromlayer-management-not-working-on/m-p/10078#M881</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Curtis,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;The script was indeed running in the foreground; it's not that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I fixed the issue by getting a reference to the layer to update by calling ListLayers like so:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_1415363574060867" jivemacro_uid="_1415363574060867"&gt;
&lt;P&gt;layerToUpdate = arcpy.mapping.ListLayers(mxd, &lt;SPAN class="string"&gt;"climate_pp_geq1020"&lt;/SPAN&gt;, df)[0]&lt;/P&gt;
&lt;P&gt;arcpy.ApplySymbologyFromLayer_management(layerToUpdate, "//VBOXSVR/data/10min/binarySymbology.lyr")&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have no idea why this is necessary within the script but not the Python console. Can someone please explain?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Nov 2014 12:34:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/applysymbologyfromlayer-management-not-working-on/m-p/10078#M881</guid>
      <dc:creator>MauricioSilveira</dc:creator>
      <dc:date>2014-11-07T12:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: ApplySymbologyFromLayer_management not working on script tool. Works on Python console.</title>
      <link>https://community.esri.com/t5/python-questions/applysymbologyfromlayer-management-not-working-on/m-p/10079#M882</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would image the problem is that in your script tool you are not providing enough information for it to find the layer. The &lt;SPAN style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold;"&gt;ApplySymbologyFromLayer&lt;/SPAN&gt; tool takes a FeatureLayer as input (it says that in the help) but just giving it a name (which you did) could be interpreted as a FeatureClass, an object that does not support symbology. So by using the ListLayers approach you are actually providing the tool with a FeatureLayer object. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Nov 2014 13:18:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/applysymbologyfromlayer-management-not-working-on/m-p/10079#M882</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2014-11-07T13:18:28Z</dc:date>
    </item>
  </channel>
</rss>

