Select to view content in your preferred language

Import Python script to model in ARCMap

5737
8
10-23-2015 07:37 AM
TerryGustafson
Frequent Contributor

I have a model I built in ArcMap.  I exported it to a python script and made some changes.  Can I import this python script back into model builder?

0 Kudos
8 Replies
JakeSkinner
Esri Esteemed Contributor
TerryGustafson
Frequent Contributor

Jake,

When I add the script to the model and run it, it gives the following error..  What I don't understand is that when I run the model before exporting it to the python script it does not hang on the LocateFeaturesAlongRoute.  Is there a different syntax in python for this?  The input is a line and a table and the output is a point..  Here is the error I get.. Its not even getting to the code that I made changes to..

0 Kudos
TerryGustafson
Frequent Contributor

My first try I created a Python toolbox and received the same error message..

0 Kudos
JakeSkinner
Esri Esteemed Contributor

Try adding the following line to your python script.  You will to add this after the 'import arcpy' line.

arcpy.env.overwriteOutput = 1

This will allow the script to overwrite output if it already exists.

TerryGustafson
Frequent Contributor

Jake, well I was rooting for your Eagles last night, cant stand Carolina..  I entered that line of code but still get this attached error.

0 Kudos
DanPatterson_Retired
MVP Emeritus

overwriteoutput doesn't work in a number of hard to nail down cases, but your error says that the first point already exists and it appears to be of the wrong type(?).  You might try it after a manual delete and restart of arcmap to see if that is the problem.  If it is remnant data you may have to use Delete_management to delete stuff that already exists

curtvprice
MVP Esteemed Contributor

In my experience, the most common situation where overwrite output does not work is if you have an active layer in memory (say in ArcMap) pointing to a dataset that you are trying to overwrite with your script - and the layer is not a parameter, so the script doesn't "know about" the layer well enough to zap the file lock.

My guess is when you are running in ModelBuilder your model elements are pointing to ArcMap layers so the delete works.

0 Kudos
TerryGustafson
Frequent Contributor

seems to clear memory now but still get this error..

The type of out_event_properties does not match the type of in_features.

0 Kudos