<?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: MakeXYEventLayer No Errors, but No Results in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/makexyeventlayer-no-errors-but-no-results/m-p/294080#M22760</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I know this is an old thread but did you ever solve this.&amp;nbsp; I have the same issue in 9.3.1 and can't for the life of me figure it out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Chuck&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 22 Feb 2012 13:36:44 GMT</pubDate>
    <dc:creator>CharlesMcCready</dc:creator>
    <dc:date>2012-02-22T13:36:44Z</dc:date>
    <item>
      <title>MakeXYEventLayer No Errors, but No Results</title>
      <link>https://community.esri.com/t5/python-questions/makexyeventlayer-no-errors-but-no-results/m-p/294079#M22759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am writing a python script that batch processes some creation of XY events based on csv tables.&amp;nbsp; The script is set up as a tool where the user provides 3 fields (the first two are needed to find the specific csv file and the second is the path to all of the csv data).&amp;nbsp; Anyway, when I run the tool it processes with no errors, but the XY Event Layer is not added to the proper data frame or the map at all.&amp;nbsp; However, when I run snippets of the code in the ArcMap python window it works and the event layer is added to the map appropriately.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the code, I tried to simplify it a bit:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, sys
from arcpy import env

str1 = sys.argv[1]
str2 = sys.argv[2]
filesPath = sys.argv[3]
env.workspace = filesPath

# Update file path
filesPath +=&amp;nbsp; str1 + str2

# Set mxd file and get a list of data frames
mxd = arcpy.mapping.MapDocument("Current")
dfList = arcpy.mapping.ListDataFrames(mxd)

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Loops through data frame and adds XY events for csv files
&amp;nbsp;&amp;nbsp;&amp;nbsp; for df in dfList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if df.name == "2010":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.activeView = df
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fileTemp = filesPath
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fileTemp += df.name + ".csv"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outLayer = str1 + str2 + df.name + "_XYEvents"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeXYEventLayer_management('"' + fileTemp + '"', "X", "Y", outLayer)

except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The weird thing is, if I try to run it again it tells me the file name already exists.&amp;nbsp; So it appears that it created the event layer, but it was just not added to the map.&amp;nbsp; I tried to use AddLayer, but python did not like that.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Jan 2011 18:07:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/makexyeventlayer-no-errors-but-no-results/m-p/294079#M22759</guid>
      <dc:creator>JohnStephens</dc:creator>
      <dc:date>2011-01-04T18:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: MakeXYEventLayer No Errors, but No Results</title>
      <link>https://community.esri.com/t5/python-questions/makexyeventlayer-no-errors-but-no-results/m-p/294080#M22760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I know this is an old thread but did you ever solve this.&amp;nbsp; I have the same issue in 9.3.1 and can't for the life of me figure it out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Chuck&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2012 13:36:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/makexyeventlayer-no-errors-but-no-results/m-p/294080#M22760</guid>
      <dc:creator>CharlesMcCready</dc:creator>
      <dc:date>2012-02-22T13:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: MakeXYEventLayer No Errors, but No Results</title>
      <link>https://community.esri.com/t5/python-questions/makexyeventlayer-no-errors-but-no-results/m-p/294081#M22761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here is an example on how I was able to add an XY event layer to an MXD (using arcpy for ArcGIS 10):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
from arcpy import mapping
env.workspace = r"C:\TEMP\Python\test.gdb"
env.overwriteOutput = 1

table = "XY"

#Make XY event layer
arcpy.MakeXYEventLayer_management(table, "X", "Y", "XY_event")

#Save XY event to a layer file
arcpy.SaveToLayerFile_management("XY_event", r"C:\temp\Python\XY_event.lyr")

#Add layer file to MXD
mxd = mapping.MapDocument(r"C:\temp\python\Airports.mxd")
for df in mapping.ListDataFrames(mxd):
&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr = mapping.Layer(r"C:\temp\python\XY_event.lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp; mapping.AddLayer(df, lyr)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshTOC()
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshActiveView()

mxd.save()&amp;nbsp; 

del lyr, mxd, df&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:08:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/makexyeventlayer-no-errors-but-no-results/m-p/294081#M22761</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T14:08:42Z</dc:date>
    </item>
    <item>
      <title>Re: MakeXYEventLayer No Errors, but No Results</title>
      <link>https://community.esri.com/t5/python-questions/makexyeventlayer-no-errors-but-no-results/m-p/294082#M22762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The arcpy example just posted by Jake S seems like it should address your original issue.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but I think these extra quotes may cause trouble:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeXYEventLayer_management('"' + fileTemp + '"', "X", "Y", outLayer)
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;instead:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeXYEventLayer_management(fileTemp, "X", "Y", outLayer)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:08:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/makexyeventlayer-no-errors-but-no-results/m-p/294082#M22762</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T14:08:45Z</dc:date>
    </item>
  </channel>
</rss>

