Thanks mzcoyle for replying to my thread.
I tried substituting some of my code for the code that you sent (script below) but I couldn't get it to work. It came up with the following error -
<type 'exceptions.NameError'>: name 'path' is not defined
Failed to execute (tryRiver).
I am also not sure why I was using a cursor - I thought I needed this to search through the fieldname (called type) for rivertypes (called link). I'm new to scripting and all I want to do is create an Arc tool based on arcpy scripting that lets a user navigate to the feature class (Rio_Panuco) and lets them select "type" = 'link' (fieldname = attribute) and saves the feature to a new layer.
I've noticed that the select by attributes tool required a layer as input and not a dataset so I couldn't get that to work and I tried basic make feature layer commands. I can make a feature layer from a feature class using user input but I cannot select only fields whose type = link and then save it to a new layer.
I would appreciate any further help or suggestions on this.
Code was -
# extract features by attrtibute
# import system modules
import arcpy
from arcpy import env
# get user supplied path, layers and fields
path is workspace
path = arcpy.GetParameterAsText(0)
# riverLayer is Rio_Panuco_Lyr Feature Layer
inputLayer = arcpy.GetParameterAsText(1)
# confluence is river type 'link' and is a string
confluence = arcpy.GetParameterAsText(2)
whereClause = "{0} = '{1}'".format(arcpy.AddFieldDelimiters(inputLayer, typeField), confluence)
# typeField is fieldname 'type' and is SQL expression
typeField = arcpy.GetParameterAsText(3)
# set output location
outputLayer = arcpy.GetParameterAsText()
# set overwrite option
# arcp.overwriteOutput = true
# error trapping measures
try:
# make a layer from the feature class
arcpy.MakeFeatureLayer_management(inputLayer, "River_lyr")
# select layer by attribute
arcpy.SelectLayerByAttribute_management("River_lyr", "SelectionRiverLayer", whereClause)
# write selected features to a new featureclass
arcpy.CopyFeatures_management("River_lyr", "SelectionRiverLayer")
except:
print arcpy.GetMessages()
Kind regards
Scottaidh