Hi, I'm trying to build a script, my first, so that it would create another version of some polygons in a shapefile (per example zoning)by erasing some polygons contained in a different shapefile (called hydro). I don't have a Pro license, so I use the "Union then delete" method instead of the erase tool. I don't want the attributes from the hydro table. I want to duplicate the script to apply those modification to other shapefiles. So here is what I found for the moment:
# Import the system modules
import arcpy
from arcpy import env
# Set the current workspace
# (to avoid having to specify the full path to the feature classes each time)
env.workspace = "c:/data/data.gdb"
# For first layer
#Turn off all fields of hydro.shp so when union is done, the attributes table will only keep the fields from "zoning", leaving out the turned off fields of "hydro"
#Can't find script lines for that
#union layerName with hydro.shp
#Source: http://help.arcgis.com/En/Arcgisdesktop/10.0/Help/index.html#//00080000000s000000
arcpy.Union_analysis (["layerName", "hydro", "layerName_union", "ALL")
#select FID_hydro <> -1
#Source: http://help.arcgis.com/En/Arcgisdesktop/10.0/Help/index.html#//001700000071000000)
arcpy.SelectLayerByAttribute_management ("layerName_union", "NEW_SELECTION", " [FID_hydro] <> '-1' ")
#If selection > 0, delete FID_hydro <> -1
#Source: http://help.arcgis.com/EN/ARCGISDESKTOP/10.0/HELP/index.html#//001700000036000000
if int(arcpy.GetCount_management(layerName_union).getOutput(0)) > 0:
arcpy.DeleteFeatures_management(layerName_union)
#export data layerName_union as shapefile
#Source: http://resources.arcgis.com/en/help/main/10.1/index.html#//001200000020000000
arcpy.FeatureClassToFeatureClass_conversion("layerName_union","C:/Chemin/vers/dossier","layerName_noHydro.shp")
# Repeat for other layers
Anyone know how to use script to turn off all the field of a layer?
Would those steps work? Is there something missing?
Thanks,