addLayer is what am trying to use now but I keep getting this error:
Traceback (most recent call last):
File "\\c:\MyLocation\Tools\Scripts\Changes.py", line 39, in <module>
df = arcpy.mapping.ListDataFrames(mxd, "Update")[0]
IndexError: list index out of range
This one has me stumped.
Here is the code:
# Import arcpy module
import arcpy
#Import Time and Date
import time
import datetime
#Sets a variable to hold today's date in year month day (yyyymmdd)format to tag feature output name with the current date
currentdate = datetime.date.today().strftime("%Y""%m""%d")
# Overwrite pre-existing files
arcpy.env.overwriteOutput = True
# Local variables:
Changes = "\\\\c:\\MyLocation\\\\Working_Data.mdb\\Changes"
Changes_Layer = "Changes_Layer"
Update = "\\\\c:\\MyLocation\\MyGeo.gdb\\Updates\\Updates"+str(currentdate)
# Process: Make XY Event Layer
arcpy.MakeXYEventLayer_management(Changes, "longitude", "latitude", Changes_Layer, "", "")
# Process: Feature To Point
arcpy.FeatureToPoint_management(Changes_Layer, Updates, "CENTROID")
#Add layer into primary map document
addLayer = Changes_Layer +str(currentdate)
mxd = arcpy.mapping.MapDocument("\\\\c:\myLocation\\MyMap.mxd
df = arcpy.mapping.ListDataFrames(mxd, "Update")[0]
arcpy.mapping.AddLayer(df, addLayer, "TOP")