I'm trying to run a very simple python script to create a feature layer from a shapefile.
The original script read as follows (I added the two print statements at the end to verify upon completion that:
1) the output I was trying to create was created (Exists(the layer I was trying to create)) and
2) that the script was recognizing the path name by asking if a known folder existed
# Import system modules
import arcpy
from arcpy import env
# Set overwrite option
arcpy.env.overwriteOutput = True
# Set workspace
# arcpy.env.workspace = r"H:\Python\Python_Cookbook\data\TravisCounty"
# Make feature layer to hold selection.
Bldgs = r"H:\Python\Python_Cookbook\data\TravisCounty\BuildingPermits.shp"
Bldg_Lyr = r"H:\Python\Python_Cookbook\data\TravisCounty\Building.lyr"
arcpy.MakeFeatureLayer_management(Bldgs, Bldg_Lyr)
print arcpy.Exists(
r"H:\Python\Python_Cookbook\data\TravisCounty\Building.lyr")
print arcpy.Exists(
r"H:\Python\Python_Cookbook\data\TravisCounty")
The result from this first script was that no layer appeared in Catalog, and the print statements returned False and True. So the script recognized the existing folder, but did not find the layer it was supposed to create.
My second attempt was to comment out the workspace and to assign variables to the full paths instead. (see below).
# Import system modules
import arcpy
from arcpy import env
# Set overwrite option
arcpy.env.overwriteOutput = True
# Set workspace
# arcpy.env.workspace = r"H:\Python\Python_Cookbook\data\TravisCounty"
# Make feature layer to hold selection.
Bldgs = r"H:\Python\Python_Cookbook\data\TravisCounty\BuildingPermits.shp"
Bldg_Lyr = r"H:\Python\Python_Cookbook\data\TravisCounty\Building.lyr"
arcpy.MakeFeatureLayer_management(Bldgs, Bldg_Lyr)
print arcpy.Exists(
r"H:\Python\Python_Cookbook\data\TravisCounty\Building.lyr")
print arcpy.Exists(
r"H:\Python\Python_Cookbook\data\TravisCounty")
This seemed to work better: My print statements returned True and True this time around.
HOWEVER: When I opened the ArcCatalog, I still couldn't find the new layer that was supposed to have been created. Copying the full path (that just returned 'True' to the exists() call) into the Location bar of ArcCatalog returned a message that it was "...and invalid or non-existent directory."
ps. Is there a way to apply the codewrapper without manually entering four spaces before each line of code?