<?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: &amp;quot;CURRENT&amp;quot; mxd issues when called from a tool and symbology not updating in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/amp-quot-current-amp-quot-mxd-issues-when-called/m-p/11604#M949</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Found one answer...tool HAS to run in the foreground only (can not be in the background). The other two issues remain (i.e the symbology is not being updated).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 19 Mar 2012 21:54:46 GMT</pubDate>
    <dc:creator>George_ChandeepCorea</dc:creator>
    <dc:date>2012-03-19T21:54:46Z</dc:date>
    <item>
      <title>&amp;quot;CURRENT&amp;quot; mxd issues when called from a tool</title>
      <link>https://community.esri.com/t5/python-questions/amp-quot-current-amp-quot-mxd-issues-when-called/m-p/11603#M948</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This should be a really simple process but I am having issues. I want to search a workspace for all files with a certain string and then add them to the current workspace with a selected symbology. When the mxd name is hardcoded the code works fine but I need it to update the currently open map. It works fine with mapdocument("current") when run in the python window from arcmap but I need it to work as a tool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Issues&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; 1. Error [[: Object: CreateObject cannot open map document]] I have to set the map doc to be the current workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; 2. When run in the python window the symbology is not updated. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; 3. It should only update the map frame/toc once everything is added&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import os, arcpy, arcpy.mapping
from arcpy import env

GDB = arcpy.GetParameterAsText(0)
Text = arcpy.GetParameterAsText(1)
symbologyLayer = arcpy.GetParameterAsText(2)
#OutputGDB = arcpy.GetParameterAsText(3)

arcpy.env.workspace=GDB
mxd=arcpy.mapping.MapDocument("CURRENT")
list=arcpy.ListFeatureClasses('*'+Text+'*')

for layer in list:
&amp;nbsp;&amp;nbsp;&amp;nbsp; dataFrame = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; addLayer = arcpy.mapping.Layer(layer)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.AddLayer(dataFrame, addLayer, "BOTTOM")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ApplySymbologyFromLayer_management (addLayer, symbologyLayer)

# Clean up the MapDocument object by deleting it
#del mxd

arcpy.RefreshActiveView()
arcpy.RefreshTOC()
ERROR DETAILS
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Messages&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Executing: ProcessDatasets22 P:\2012\Job_044_DM_Radio_Propogation\Working\FinalPropogation\cb_BEL07\working\bel07.gdb _dow P:\2012\Job_044_DM_Radio_Propogation\Working\signal_strength_poly.lyr Start Time: Mon Mar 19 14:11:27 2012 Running script ProcessDatasets22... : &lt;/SPAN&gt;&lt;STRONG&gt;Object: CreateObject cannot open map document Failed to execute&lt;/STRONG&gt;&lt;SPAN&gt; (ProcessDatasets22). Failed at Mon Mar 19 14:11:27 2012 (Elapsed Time: 0.00 seconds)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 15:54:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-quot-current-amp-quot-mxd-issues-when-called/m-p/11603#M948</guid>
      <dc:creator>George_ChandeepCorea</dc:creator>
      <dc:date>2021-12-12T15:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: "CURRENT" mxd issues when called from a tool and symbology not updating</title>
      <link>https://community.esri.com/t5/python-questions/amp-quot-current-amp-quot-mxd-issues-when-called/m-p/11604#M949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Found one answer...tool HAS to run in the foreground only (can not be in the background). The other two issues remain (i.e the symbology is not being updated).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Mar 2012 21:54:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-quot-current-amp-quot-mxd-issues-when-called/m-p/11604#M949</guid>
      <dc:creator>George_ChandeepCorea</dc:creator>
      <dc:date>2012-03-19T21:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: "CURRENT" mxd issues when called from a tool</title>
      <link>https://community.esri.com/t5/python-questions/amp-quot-current-amp-quot-mxd-issues-when-called/m-p/11605#M950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you tried arcpy.mapping.UpdateLayer() instead of ApplySymbologyFrom layer?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Mar 2012 19:50:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-quot-current-amp-quot-mxd-issues-when-called/m-p/11605#M950</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2012-03-20T19:50:32Z</dc:date>
    </item>
  </channel>
</rss>

