<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Model exported to python script fails with Error 000728 in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/model-exported-to-python-script-fails-with-error/m-p/233454#M8033</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Why dont you use Copy Features to copy the Feature Set to a Feature Class in your scratch workspace. Then, Make the Feature Layer off of that.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Feb 2011 17:35:32 GMT</pubDate>
    <dc:creator>KarenRobine</dc:creator>
    <dc:date>2011-02-23T17:35:32Z</dc:date>
    <item>
      <title>Model exported to python script fails with Error 000728</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/model-exported-to-python-script-fails-with-error/m-p/233453#M8032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Executing: Script "Feature Set"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Mon Feb 21 14:59:28 2011&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Running script Script...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;: Failed to execute. Parameters are not valid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000728: Field PHONE_NUMB does not exist within table&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (ExportXYv).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (Script).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed at Mon Feb 21 14:59:29 2011 (Elapsed Time: 1.00 seconds)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# ---------------------------------------------------------------------------
# Script5.py
# Created on: 2011-02-21 14:50:53.00000
#&amp;nbsp;&amp;nbsp; (generated by ArcGIS/ModelBuilder)
# Usage: Script5 &amp;lt;Feature_Set&amp;gt; 
# Description: 
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Script arguments
Feature_Set = arcpy.GetParameterAsText(0)
if Feature_Set == '#' or not Feature_Set:
&amp;nbsp;&amp;nbsp;&amp;nbsp; 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")


&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:13:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/model-exported-to-python-script-fails-with-error/m-p/233453#M8032</guid>
      <dc:creator>TimothyMichael</dc:creator>
      <dc:date>2021-12-12T16:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: Model exported to python script fails with Error 000728</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/model-exported-to-python-script-fails-with-error/m-p/233454#M8033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Why dont you use Copy Features to copy the Feature Set to a Feature Class in your scratch workspace. Then, Make the Feature Layer off of that.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Feb 2011 17:35:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/model-exported-to-python-script-fails-with-error/m-p/233454#M8033</guid>
      <dc:creator>KarenRobine</dc:creator>
      <dc:date>2011-02-23T17:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: Model exported to python script fails with Error 000728</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/model-exported-to-python-script-fails-with-error/m-p/233455#M8034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;For the purpose of the script I'd rather not generate a temporary feature class on the server.&amp;nbsp; I did figure out a work around to my problem, though.&amp;nbsp; I just removed the Output_Layer_Name variable and replaced it with AddressPoints_Layer in ExportXYv_stats process. So the final part now looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
arcpy.ExportXYv_stats(AddressPoints_Layer, "PHONE_NUMB", "COMMA", outputFile, "NO_FIELD_NAMES")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and the script is working properly now, exporting attributes of the selected features.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:48:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/model-exported-to-python-script-fails-with-error/m-p/233455#M8034</guid>
      <dc:creator>TimothyMichael</dc:creator>
      <dc:date>2021-12-11T11:48:36Z</dc:date>
    </item>
  </channel>
</rss>

