I'm trying to get a few models to run via python after being initialized from Windows Scheduler. (Windows Server 2008 r2, acrmap 10.1.1, python 2.7.2)
I have been able to get two of my models to run this way after exporting to python and setting windows scheduler to execute the python script. however, there is still one model that is failing, but only when run via python. Runs successful from the model / toolbox in our Enterprise GDB, no problems at all. I'm, not very versed in python so I can't really decipher what this error (below) means outside of the error code = append issue with mis-matched fields.
The model that runs successfully, is using a table view, geocoding, appending points to a feature class in our Enterprise GDB.
The model that fails is using a table view, plotting x/y, appending points to a feature class in our Enterprise GDB.This one seems to fail on the append. BUT only when run from python.
Runs successful from the model / toolbox in our Enterprise GDB, just not from python shell. What is going on here, what ? anyone have insight? Please let me know if you need additional info from this tool or error.
Fail message::
File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 3560, in Append
raise e
ExecuteError: ERROR 000224: Cannot insert features
Failed to execute (Append).
Solved! Go to Solution.
Try exporting the table view to a new feature class and then appending the features from the feature class. May be spatial reference related...
Try exporting the table view to a new feature class and then appending the features from the feature class. May be spatial reference related...
You can run a model from a python script directly, without export. Here's an (untested) script, assuming you have a toolbox named "MyToolbox" with a model named "MyModel".
import arcpy try: arcpy.ImportToolbox("c:/users/username/Documents/ArcGIS/MyToolbox.tbx", "mytools") arcpy.MyModel_mytools("arg1", "arg2") arcpy.AddMessage(arcpy.GetMessages()) except Exception as msg: arcpy.AddError("Python messages:\n{}".format(msg)) arcpy.AddError("ArcGIS messages:\n{}".format(arcpy.GetMessages()))
Ben, Curtis. Thank you both for your replies and ideas. Let me taek a look at your suggestions (probably after the holiday) and post back with my results.
I appreciae your input!
I was able to update our model so that after the plot XY from the table view, we are now using the "Copy Features" GP tool to create a copy and have set the spatial reference set to match the projected spatial reference of the feature class that we are appending too. Previously we were appending directly from the temp layer from plotting XY process. After this change the append runs successfully!!
*one caveat, we are now seeing a mapped fields issue where the datetime field is not being written to during the append process, but that is for another thread.
Curtis: I have not had time to test your solution, so I can't say that it is not the answer to this riddle. It may be. If I get around to testing it out, I will certainly post back here for others. I can see how this would come in use for other projects we have.