I'm running a python script from arccatalog and it works, however, I am trying to add layers to an mxd and need to declare the data frame. I keep getting this error message.
type 'exceptions.AttributeError': 'unicode' object has no attribute '_arc_object' Failed to execute (StepByStep)
Selection of my code is below.
# Import arcpy module
import arcpy
import sys
# Licenses
arcpy.CheckOutExtension("3D")
arcpy.CheckOutExtension("spatial")
arcpy.OverwriteOutput = True
# Script arguments
arcpy.env.extent = "E:\\School_Test\\SchoolTest.gdb\\Extent"
arcpy.env.cellSize = "3"
mxd = arcpy.GetParameterAsText(0)
arcpy.env.scratchWorkspace = arcpy.GetParameterAsText(1)
arcpy.env.workspace = arcpy.GetParameterAsText(2)
spRef = arcpy.GetParameterAsText(3)
Survey_Data = arcpy.GetParameterAsText(4)
Survey_X = arcpy.GetParameterAsText(5)
Survey_Y = arcpy.GetParameterAsText(6)
Survey_Z = arcpy.GetParameterAsText(7)
Sample_Data = arcpy.GetParameterAsText(8)
Sample_X = arcpy.GetParameterAsText(9)
Sample_Y = arcpy.GetParameterAsText(10)
Selection_Criteria = arcpy.GetParameterAsText(11)
Site_Grid = arcpy.GetParameterAsText(12)
df = arcpy.mapping.ListDataFrames(mxd, "Layers") [0]
Below this I declare variables then geoprocessing.
Any suggestions?
arcpy.AddMessage(mxd)
immediately before you try to create the DataFrame object, and then run it again to see ifmxd
is set to what you think.