Select to view content in your preferred language

Overwrite Existing File - Model Builder

18623
13
10-29-2013 11:47 AM
MikeBly
Regular Contributor
Hey,

I have a simple model that converts a feature class to shapefile, drops unneeded fields and then reprojects. Thats it.

Problem is the model will not run unless I first go and delete the outputs from any previous run of the model. Is there a way in the final geoprocessing step or another tool that will allow the process to overwrite any existing file?

Simple enough I would think..........

Thanks,

Mike
13 Replies
lelaharrington
Regular Contributor

Did you ever get this process completed. i have a similar problem, i am looking to take features from SDE1 and send them to SDE2 and overwrite the features in SDE 2. i tried features to features tool but it doesn overwrite it. it adds a _1 after the feature name.

0 Kudos
TimWitt2
MVP Alum

Lela,

you could always create your model in modelbuilder and then export it to python. Then you could add code that will check if certain files exist and if they do, delete them. Like this:

env.workspace = "Space where your output will be"
if arcpy.Exists("your feature"):
    arcpy.Delete_management("your featuree")

That's how I do it.

Tim

0 Kudos
lelaharrington
Regular Contributor

that is what i am doing is starting in model builder and then exporting out into python after the system is proven. i just can figure out how to get model builder to overwrite the feature rather than add the _1 to it.

0 Kudos
Marco_AlejandroBonilla
Frequent Contributor

for python, i think you must use the command line after importing arcpy: arcpy.env.overwriteOutput = True

lelaharrington
Regular Contributor

if i put the model builder and save it as a python script where would i place this code for it to run? 

Thank you

Lela Harrington

0 Kudos
ShitalDhakal__GISP
Frequent Contributor

Did you figure out where to put your code to run?

0 Kudos
Marco_AlejandroBonilla
Frequent Contributor

Did you try setting your geoprocessing options for overwriting outputs??Captura.JPG

I think this must help

lelaharrington
Regular Contributor

where is that located? 

Thank you

Lela Harrington

0 Kudos
Marco_AlejandroBonilla
Frequent Contributor

In the menu bar, click on "geoprocessing", then click on "geoprocessing options"Captura2.JPG

😃