10

I am having trouble running a script tool that I just created in Arc 10.1. The script runs fine in PythonWin, but when I create a script tool with it, the tool seems to not want to accept folders or geodatabases as its output workspace. I have the output parameter (argument) set as both an output and a workspace in the script tool, but it still keeps giving me an error that the "Dataset.....already exists"

I'm a new user, so I can't post a picture, but the error is 000725

Here is my script, if that helps out.

import arcpy
#allow for overwrites
arcpy.env.overwriteOutput = True

#set the workspace
inWorkspace = arcpy.GetParameterAsText (0)

#set the erase feature
eraseFeature = arcpy.GetParameterAsText (1)

#set the output workspace
outWorkspace = arcpy.GetParameterAsText (2)


#get a list of all the features in the workspace
arcpy.env.workspace = inWorkspace
featureClassList = arcpy.ListFeatureClasses()

try:

    #loop through all of the features in the workspace
    for featureClass in featureClassList:

        #construct the output path
        outEraseFeature = outWorkspace + "\\erase_" + featureClass

        #perform erase
        arcpy.Erase_analysis(featureClass, eraseFeature, outEraseFeature)

        arcpy.AddMessage("Wrote clipped file " + outEraseFeature + ". ")
        print "Wrote clipped file " + outEraseFeature + ". "

except:

    # Report if there was an error
    arcpy.AddError("Could not erase feature classes")
    print "Could not erase feature classes"
    print arcpy.GetMessages()
1
  • 4
    If it really does already exist you can try adding arcpy.env.overwriteOutput =True Commented Dec 1, 2012 at 0:50

2 Answers 2

6

I found out that if I changed the direction of the output workspace from 'output' to 'input', then the script ran without an error.

1
  • thanks a lot - this hint finally solved my problem I have been working on for hours. Within my created python script an output folder should be specified to store a bunch of raster results. Setting it to Output created errors, now as I set it to Input it immediately worked.
    – the_chimp
    Commented Mar 9, 2016 at 5:24
4

It is for your own protection. To not get that error, you need to enable this option:Overwrite Outputs.

Alternately, change your Output_Workspace to an input parameter rather than an output parameter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.