tmichael81

Model exported to python script fails with Error 000728

Discussion created by tmichael81 on Feb 21, 2011
Latest reply on Feb 24, 2011 by tmichael81
Hello,

I have created a small model that uses three tools - Make Feature Layer, Select Layer by Location, and Export Feature Attribute to ASCII (screenshot is attached). The model works great. I then exported the model to python and tried adding it to a toolbox as a script, which produces an error when run:

Executing: Script "Feature Set"
Start Time: Mon Feb 21 14:59:28 2011
Running script Script...
<class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid.
ERROR 000728: Field PHONE_NUMB does not exist within table
Failed to execute (ExportXYv).

Failed to execute (Script).
Failed at Mon Feb 21 14:59:29 2011 (Elapsed Time: 1.00 seconds)

I am importing the python script unmodified, just as it was exported from Model Builder. I know the field should be there; as a test I stepped through the first part of the script using the Python window, and when the feature layer was created all of the fields were present. The exported script is below; does anyone know what I can do to work around this error?


# ---------------------------------------------------------------------------
# Script5.py
# Created on: 2011-02-21 14:50:53.00000
#   (generated by ArcGIS/ModelBuilder)
# Usage: Script5 <Feature_Set>
# Description:
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Script arguments
Feature_Set = arcpy.GetParameterAsText(0)
if Feature_Set == '#' or not Feature_Set:
    Feature_Set = "in_memory\\{BF09C0DA-86F6-4FED-962A-77D65E6DC987}" # provide a default value if unspecified

# Local variables:
AddressPoints = "AddressPoints"
Output_Layer_Name = Feature_Set
Test2_txt = Output_Layer_Name
AddressPoints_Layer = "AddressPoints_Layer"

# Process: Make Feature Layer
arcpy.MakeFeatureLayer_management(AddressPoints, AddressPoints_Layer, "", "", "OBJECTID OBJECTID VISIBLE NONE;Shape Shape VISIBLE NONE;PHONE_NUMB PHONE_NUMB VISIBLE NONE;")

# Process: Select Layer By Location
arcpy.SelectLayerByLocation_management(AddressPoints_Layer, "INTERSECT", Feature_Set, "", "NEW_SELECTION")

# Process: Export Feature Attribute to ASCII
arcpy.ExportXYv_stats(Output_Layer_Name, "PHONE_NUMB", "COMMA", Test2_txt, "NO_FIELD_NAMES")




Thanks!

Attachments

Outcomes