I'm fairly new to arcpy, and I don't understand why this one line of code executes in immediate mode, but not in a stand alone script. arcpy.SelectLayerByLocation_management("ProjectsLayer", "INTERSECT", "RegionOverlay")
When I run my .py script in ArcMap (shown below), my dialog box shows that the script completed successfully, but I don't see any evidence of a selection. Performing my code line by line in ArcMap's built-in python window, however, selects and highlights the applicable records. Must I add something more to my standalone script to perform this selection task?import arcpy arcpy.env.workspace = 'PATH_TO_RESOURCE' arcpy.env.overwriteOutput = True inFeatureClass = arcpy.GetParameterAsText(0) if inFeatureClass == "Elderly block groups": selectedLayer = 'PATH_TO_RESOURCE' elif inFeatureClass == "Minorities": selectedLayer = 'PATH_TO_RESOURCE' mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd,"*")[0] newlayer = arcpy.mapping.Layer(selectedLayer) projects = 'PATH_TO_RESOURCE' projectsLayer = arcpy.mapping.Layer(projects) arcpy.mapping.AddLayer(df, newlayer) arcpy.mapping.AddLayer(df, projectsLayer, "TOP") arcpy.MakeFeatureLayer_management(projects, "ProjectsLayer") arcpy.MakeFeatureLayer_management(newlayer, "RegionOverlay") arcpy.SelectLayerByLocation_management("ProjectsLayer", "INTERSECT", "RegionOverlay") arcpy.MakeFeatureLayer_management("ProjectsLayer", "OverlayProjects")