So, this is my code:
import arcpy
from arcpy import env
import os
#
env.workspace = arcpy.GetParameterAsText[0] #r"D:\Lorna\Project\Working\Outputs\LooseClip"
outLocation = arcpy.GetParameterAsText[1] #r"D:\Lorna\Project\Working\Outputs\ClippedFeaturesGDB.gdb"
# Use the ListFeatureClasses function to return a list of
# all shapefiles in workspace.
#
fcList = arcpy.ListFeatureClasses()
#shapefiles are named <feature>Clip_<PAid>.shp
#this loop takes each fc, calculates a field which is populated by the PAid out of its file name
#and then appends the shapefile to the appropriate feature class.
for fc in fcList:
myPA = fc[fc.find("_")+1:fc.find(".")]
arcpy.CalculateField_management(env.workspace + os.sep + fc, "PAid", "\""+myPA+"\"", "VB", "")
myFeature = fc[:fc.find("Clip")]
arcpy.Append_management(fc, outLocation + os.sep + "Clip"+ myFeature)
print myFeature
The user has to input each parameter as a string. It basically takes the features from a folder, puts an id into a field and appends them together (see comments). This works perfectly on its own, run from pythonwin, but fails miserably when I try to run it from model builder.
<type 'exceptions.TypeError'>: 'function' object is unsubscriptable
is the error I get.
Does anyone know what the problem is? I'm new to this so be nice!
Thanks for your help,
Lorna