<?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 Copy Features - Recieveing Catch All Error Message in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/copy-features-recieveing-catch-all-error-message/m-p/60781#M4865</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am writing a python code to select features from a feature layer then copying the selected feature(s) to a new feature class. The code succeeds at selecting the features but when it goes to copy these features I get a catch-all error message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000210: Cannot create output CountyBoundary_Selection.shp&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (CopyFeatures).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed at Tue Oct 16 14:34:23 2012 (Elapsed Time: 0.00 seconds)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have read this&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://help.arcgis.com/EN/ARCGISDESKTOP/10.0/HELP/index.html#//00vp0000000n000210.htm" rel="nofollow" target="_blank"&gt; ESRI article&lt;/A&gt;&lt;SPAN&gt;, and have made sure that there is not a lock on any files and have tried to save the new feature class to a new location. Any other suggestions?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also if I use the feature class to feature class tool instead of the Copy Features tool the script works. So I'll go with this for now but it would be nice to know for the future.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, os&amp;nbsp; workspace = "C:/Temp"&amp;nbsp; print "Workspace set to:", workspace arcpy.AddMessage("Workspace set to: "+workspace) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.overwriteOutput=True&amp;nbsp; def whereClause(table, field, values): &amp;nbsp;&amp;nbsp;&amp;nbsp; """Takes a semicolon-delimited list of values and constructs a SQL WHERE &amp;nbsp;&amp;nbsp;&amp;nbsp; clause to select those values within a given field and table."""&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # Add field delimiters &amp;nbsp;&amp;nbsp;&amp;nbsp; fieldDelimited = arcpy.AddFieldDelimiters(arcpy.Describe(table).path, field)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # Split multivalue at semicolons and strip quotes &amp;nbsp;&amp;nbsp;&amp;nbsp; valueList = [value[1:-1] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (value.startswith("'") and value.endswith("'")) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else value for value in values.split(';')]&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # Determine field type &amp;nbsp;&amp;nbsp;&amp;nbsp; fieldType = arcpy.ListFields(table, field)[0].type&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # Add single-quotes for string field values &amp;nbsp;&amp;nbsp;&amp;nbsp; if str(fieldType) == 'String': &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; valueList = ["'%s'" % value for value in valueList]&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # Format WHERE clause in the form of an IN statement &amp;nbsp;&amp;nbsp;&amp;nbsp; whereClause = "%s IN (%s)"%(fieldDelimited, ', '.join(valueList)) &amp;nbsp;&amp;nbsp;&amp;nbsp; return whereClause&amp;nbsp; def outName(input,post="Out",fileExtension="shp"): &amp;nbsp;&amp;nbsp;&amp;nbsp; """Returns output name.""" &amp;nbsp;&amp;nbsp;&amp;nbsp; outName=os.path.basename(input).split(".")[0]+post+"."+fileExtension &amp;nbsp;&amp;nbsp;&amp;nbsp; return outName&amp;nbsp;&amp;nbsp; #Make Feature Layer from County Boundary Feature Class InputFC = "C:\Project\ToolData\CountyBoundary.shp" OutputFL = outName(InputFC,"_Layer","lyr")&amp;nbsp; try: &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(InputFC, OutputFL) except: &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.GetMessages() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Select Attributes from County Boundary Layer Field = "CO_NAME" Counties = arcpy.GetParameterAsText(0) SQL = whereClause(OutputFL, Field, Counties)&amp;nbsp; try: &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(OutputFL,"NEW_SELECTION", SQL) &amp;nbsp;&amp;nbsp;&amp;nbsp; count = int(arcpy.GetCount_management(OutputFL).getOutput(0)) &amp;nbsp;&amp;nbsp;&amp;nbsp; print '\n',"There are", count, "counties selected from County Boundary layer.",'\n' &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except: &amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()&amp;nbsp; #Copy Selected Feature Layer to new Feature Class OutputFC = outName(InputFC,"_Selection","shp")&amp;nbsp; try: &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(OutputFL, OutputFC) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except: &amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Oct 2012 17:49:01 GMT</pubDate>
    <dc:creator>RachelAlbritton1</dc:creator>
    <dc:date>2012-10-16T17:49:01Z</dc:date>
    <item>
      <title>Copy Features - Recieveing Catch All Error Message</title>
      <link>https://community.esri.com/t5/python-questions/copy-features-recieveing-catch-all-error-message/m-p/60781#M4865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am writing a python code to select features from a feature layer then copying the selected feature(s) to a new feature class. The code succeeds at selecting the features but when it goes to copy these features I get a catch-all error message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000210: Cannot create output CountyBoundary_Selection.shp&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (CopyFeatures).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed at Tue Oct 16 14:34:23 2012 (Elapsed Time: 0.00 seconds)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have read this&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://help.arcgis.com/EN/ARCGISDESKTOP/10.0/HELP/index.html#//00vp0000000n000210.htm" rel="nofollow" target="_blank"&gt; ESRI article&lt;/A&gt;&lt;SPAN&gt;, and have made sure that there is not a lock on any files and have tried to save the new feature class to a new location. Any other suggestions?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also if I use the feature class to feature class tool instead of the Copy Features tool the script works. So I'll go with this for now but it would be nice to know for the future.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, os&amp;nbsp; workspace = "C:/Temp"&amp;nbsp; print "Workspace set to:", workspace arcpy.AddMessage("Workspace set to: "+workspace) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.overwriteOutput=True&amp;nbsp; def whereClause(table, field, values): &amp;nbsp;&amp;nbsp;&amp;nbsp; """Takes a semicolon-delimited list of values and constructs a SQL WHERE &amp;nbsp;&amp;nbsp;&amp;nbsp; clause to select those values within a given field and table."""&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # Add field delimiters &amp;nbsp;&amp;nbsp;&amp;nbsp; fieldDelimited = arcpy.AddFieldDelimiters(arcpy.Describe(table).path, field)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # Split multivalue at semicolons and strip quotes &amp;nbsp;&amp;nbsp;&amp;nbsp; valueList = [value[1:-1] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (value.startswith("'") and value.endswith("'")) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else value for value in values.split(';')]&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # Determine field type &amp;nbsp;&amp;nbsp;&amp;nbsp; fieldType = arcpy.ListFields(table, field)[0].type&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # Add single-quotes for string field values &amp;nbsp;&amp;nbsp;&amp;nbsp; if str(fieldType) == 'String': &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; valueList = ["'%s'" % value for value in valueList]&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # Format WHERE clause in the form of an IN statement &amp;nbsp;&amp;nbsp;&amp;nbsp; whereClause = "%s IN (%s)"%(fieldDelimited, ', '.join(valueList)) &amp;nbsp;&amp;nbsp;&amp;nbsp; return whereClause&amp;nbsp; def outName(input,post="Out",fileExtension="shp"): &amp;nbsp;&amp;nbsp;&amp;nbsp; """Returns output name.""" &amp;nbsp;&amp;nbsp;&amp;nbsp; outName=os.path.basename(input).split(".")[0]+post+"."+fileExtension &amp;nbsp;&amp;nbsp;&amp;nbsp; return outName&amp;nbsp;&amp;nbsp; #Make Feature Layer from County Boundary Feature Class InputFC = "C:\Project\ToolData\CountyBoundary.shp" OutputFL = outName(InputFC,"_Layer","lyr")&amp;nbsp; try: &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(InputFC, OutputFL) except: &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.GetMessages() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Select Attributes from County Boundary Layer Field = "CO_NAME" Counties = arcpy.GetParameterAsText(0) SQL = whereClause(OutputFL, Field, Counties)&amp;nbsp; try: &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(OutputFL,"NEW_SELECTION", SQL) &amp;nbsp;&amp;nbsp;&amp;nbsp; count = int(arcpy.GetCount_management(OutputFL).getOutput(0)) &amp;nbsp;&amp;nbsp;&amp;nbsp; print '\n',"There are", count, "counties selected from County Boundary layer.",'\n' &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except: &amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()&amp;nbsp; #Copy Selected Feature Layer to new Feature Class OutputFC = outName(InputFC,"_Selection","shp")&amp;nbsp; try: &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(OutputFL, OutputFC) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except: &amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Oct 2012 17:49:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copy-features-recieveing-catch-all-error-message/m-p/60781#M4865</guid>
      <dc:creator>RachelAlbritton1</dc:creator>
      <dc:date>2012-10-16T17:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Features - Recieveing Catch All Error Message</title>
      <link>https://community.esri.com/t5/python-questions/copy-features-recieveing-catch-all-error-message/m-p/60782#M4866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I see your problem - check your variable OutputFL which, as you have it set up by the outName function creates the name:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CountyBoundary_Layer.lyr&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...which is really a layer file name - not what the Copy Features tool is expecting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;By the way, if you just want to quickly fix this changing a single line (to get it running without modifying your outName function now), you can make the change:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;OutputFL = outName(InputFC,"_Layer","lyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;OuputFL = os.path.splitext(outName(InputFC,"_Layer","lyr"))[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And that should do it for now --- then you can afford to tweak your function to your liking when time suits you.&amp;nbsp; (sometimes a luxury hard afforded)&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Oct 2012 18:24:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copy-features-recieveing-catch-all-error-message/m-p/60782#M4866</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2012-10-16T18:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Features - Recieveing Catch All Error Message</title>
      <link>https://community.esri.com/t5/python-questions/copy-features-recieveing-catch-all-error-message/m-p/60783#M4867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Wayne - If I'm understanding you correctly you're saying that the input into the Copy Features tool needs to be a .shp file and not a .lyr file correct? If so, this makes me even more confused. The examples shown in ArcGIS 10.0 show that the input can be a layer file, Additionally, the Select by Attributes tool requires that the input (and therefore output) of this process is a lyr file so how can this tool be used to copy an output from this process as shown below? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Name: ExtactFeaturesByLocationAndAttribute.py&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Description: Extract features to a new feature class based on a spatial relationships to another layer AND an attribute query&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Author: ESRI&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Import system modules&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set the workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = "c:/data/mexico.gdb"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Make a layer from the feature class&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MakeFeatureLayer_management("cities", "lyr") &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Select all cities which overlap the chihuahua polygon&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByLocation_management("lyr", "intersect", "chihuahua", 0, "new_selection")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Within selected features, further select only those cities which have a population &amp;gt; 10,000&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management("lyr", "SUBSET_SELECTION", ' "population" &amp;gt; 10000 ')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Write the selected features to a new featureclass&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CopyFeatures_management("lyr", "chihuahua_10000plus")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Oct 2012 19:00:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copy-features-recieveing-catch-all-error-message/m-p/60783#M4867</guid>
      <dc:creator>RachelAlbritton1</dc:creator>
      <dc:date>2012-10-16T19:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Features - Recieveing Catch All Error Message</title>
      <link>https://community.esri.com/t5/python-questions/copy-features-recieveing-catch-all-error-message/m-p/60784#M4868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Please see my post preceding your last post.... sorry I went on an errand and didn't refresh my screen.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In short, I provided a single line to change for you to test - see if that works for you, then I can explain further if you still need more.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I was saying is that if you look at the documentation for the Copy Features tool, it is expecting a Feature Layer and this is referenced simply by name (not with the .lyr extension).&amp;nbsp; It is essentially created 'in memory' - that's why the documentation says such Feature Layers 'disappear' when you exit your ArcGIS session (unless you save outputs to a map as it is auto-added to the TOC, for example)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;More to the point, look at this, particularly the output is a Feature Layer, not to be confused with a Layer File:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Make Feature Layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000006p000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000006p000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So the output of MFL is to be passed to Copy Features and the output of the 1st tool must match the expected input of the 2nd tool, right?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are more details, but let's mull that over and stick to what you specifically need for your problem.&amp;nbsp; Try the modification I gave you - you only need to change a single line to see if it works.&amp;nbsp; Hope that helps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't think your 1st error code identified the problem, so here's your modified code, with which you may get a 'new' error, but that's part of troubleshooting! (see below):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy, os

workspace = "C:/Temp" 
print "Workspace set to:", workspace
arcpy.AddMessage("Workspace set to: "+workspace)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
arcpy.env.overwriteOutput=True

def whereClause(table, field, values):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Takes a semicolon-delimited list of values and constructs a SQL WHERE
&amp;nbsp;&amp;nbsp;&amp;nbsp; clause to select those values within a given field and table."""

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add field delimiters
&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldDelimited = arcpy.AddFieldDelimiters(arcpy.Describe(table).path, field)

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Split multivalue at semicolons and strip quotes
&amp;nbsp;&amp;nbsp;&amp;nbsp; valueList = [value[1:-1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (value.startswith("'") and value.endswith("'"))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else value for value in values.split(';')]

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Determine field type
&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldType = arcpy.ListFields(table, field)[0].type

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add single-quotes for string field values
&amp;nbsp;&amp;nbsp;&amp;nbsp; if str(fieldType) == 'String':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; valueList = ["'%s'" % value for value in valueList]

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Format WHERE clause in the form of an IN statement
&amp;nbsp;&amp;nbsp;&amp;nbsp; whereClause = "%s IN (%s)"%(fieldDelimited, ', '.join(valueList))
&amp;nbsp;&amp;nbsp;&amp;nbsp; return whereClause

def outName(input,post="Out",fileExtension="shp"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Returns output name."""
&amp;nbsp;&amp;nbsp;&amp;nbsp; outName=os.path.basename(input).split(".")[0]+post+"."+fileExtension
&amp;nbsp;&amp;nbsp;&amp;nbsp; return outName


#Make Feature Layer from County Boundary Feature Class
InputFC = "C:\Project\ToolData\CountyBoundary.shp"

# Try running again - I commented out and replaced your suspect line of code:
#OutputFL = outName(InputFC,"_Layer","lyr")
OuputFL = os.path.splitext(outName(InputFC,"_Layer","lyr"))[0]
 

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(InputFC, OutputFL)
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.GetMessages()
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
#Select Attributes from County Boundary Layer
Field = "CO_NAME"
Counties = arcpy.GetParameterAsText(0)
SQL = whereClause(OutputFL, Field, Counties)

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(OutputFL,"NEW_SELECTION", SQL)
&amp;nbsp;&amp;nbsp;&amp;nbsp; count = int(arcpy.GetCount_management(OutputFL).getOutput(0))
&amp;nbsp;&amp;nbsp;&amp;nbsp; print '\n',"There are", count, "counties selected from County Boundary layer.",'\n'
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()

#Copy Selected Feature Layer to new Feature Class
OutputFC = outName(InputFC,"_Selection","shp")

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(OutputFL, OutputFC)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:19:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copy-features-recieveing-catch-all-error-message/m-p/60784#M4868</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-10T22:19:13Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Features - Recieveing Catch All Error Message</title>
      <link>https://community.esri.com/t5/python-questions/copy-features-recieveing-catch-all-error-message/m-p/60785#M4869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for the clarification, that makes sense. I changed the def of outName to omit the file extension type, forcing me to type it in if needed, and went through make the relevant changes in the script, however I still get the same error message. For the output shapefile the current script has the .shp on the end of the file name. i also tried running the script without the .shp (so outName = CountyBoundary_Select), but that didn't work either - same error message. The revised script and error message is below&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

import arcpy, os

workspace = "C:/Temp" #Change to Set Parameter
print "Workspace set to:", workspace
arcpy.AddMessage("Workspace set to: "+workspace)

arcpy.env.overwriteOutput=True

def whereClause(table, field, values):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Takes a semicolon-delimited list of values and constructs a SQL WHERE
&amp;nbsp;&amp;nbsp;&amp;nbsp; clause to select those values within a given field and table."""

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add field delimiters
&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldDelimited = arcpy.AddFieldDelimiters(arcpy.Describe(table).path, field)

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Split multivalue at semicolons and strip quotes
&amp;nbsp;&amp;nbsp;&amp;nbsp; valueList = [value[1:-1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (value.startswith("'") and value.endswith("'"))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else value for value in values.split(';')]

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Determine field type
&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldType = arcpy.ListFields(table, field)[0].type

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add single-quotes for string field values
&amp;nbsp;&amp;nbsp;&amp;nbsp; if str(fieldType) == 'String':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; valueList = ["'%s'" % value for value in valueList]

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Format WHERE clause in the form of an IN statement
&amp;nbsp;&amp;nbsp;&amp;nbsp; whereClause = "%s IN (%s)"%(fieldDelimited, ', '.join(valueList))
&amp;nbsp;&amp;nbsp;&amp;nbsp; return whereClause

def outName(input,post="_output"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Returns output name."""
&amp;nbsp;&amp;nbsp;&amp;nbsp; outName=os.path.basename(input).split(".")[0]+post
&amp;nbsp;&amp;nbsp;&amp;nbsp; return outName


#Make Feature Layer from County Boundary Feature Class
InputFC = "C:\Project\ToolData\CountyBoundary.shp"
OutputFL = outName(InputFC,"_Layer")

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(InputFC, OutputFL)
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.GetMessages()
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
#Select Attributes from County Boundary Layer
Field = "CO_NAME"
Counties = arcpy.GetParameterAsText(0)
SQL = whereClause(OutputFL, Field, Counties)

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(OutputFL,"NEW_SELECTION", SQL)
&amp;nbsp;&amp;nbsp;&amp;nbsp; count = int(arcpy.GetCount_management(OutputFL).getOutput(0))
&amp;nbsp;&amp;nbsp;&amp;nbsp; print '\n',"There are", count, "counties selected from County Boundary layer.",'\n'
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()

#Copy Selected Feature Layer to new Feature Class
OutputFC = outName(InputFC,"_Selection.shp")

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(OutputFL,OutputFC)

&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Selected counties were exported to feature class",'\n'
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR MESSAGE:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Executing: CopyFeatures CountyBoundary_Layer CountyBoundary_Selection.shp # 0 0 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Tue Oct 16 17:01:13 2012&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000210: Cannot create output CountyBoundary_Selection.shp&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (CopyFeatures).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed at Tue Oct 16 17:01:13 2012 (Elapsed Time: 0.00 seconds)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;OR (removed the .shp from output file)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Executing: CopyFeatures CountyBoundary_Layer CountyBoundary_Selection # 0 0 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Tue Oct 16 17:02:23 2012&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000210: Cannot create output CountyBoundary_Selection&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (CopyFeatures).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed at Tue Oct 16 17:02:23 2012 (Elapsed Time: 0.00 seconds)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:19:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copy-features-recieveing-catch-all-error-message/m-p/60785#M4869</guid>
      <dc:creator>RachelAlbritton1</dc:creator>
      <dc:date>2021-12-10T22:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Features - Recieveing Catch All Error Message</title>
      <link>https://community.esri.com/t5/python-questions/copy-features-recieveing-catch-all-error-message/m-p/60786#M4870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Wayne - I saw your modified code after replying to you. I tried our code and received the same error message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Executing: CopyFeatures CountyBoundary_Layer CountyBoundary_Selection.shp # 0 0 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Tue Oct 16 17:05:10 2012&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000210: Cannot create output CountyBoundary_Selection.shp&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (CopyFeatures).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed at Tue Oct 16 17:05:10 2012 (Elapsed Time: 0.00 seconds)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Oct 2012 20:08:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copy-features-recieveing-catch-all-error-message/m-p/60786#M4870</guid>
      <dc:creator>RachelAlbritton1</dc:creator>
      <dc:date>2012-10-16T20:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Features - Recieveing Catch All Error Message</title>
      <link>https://community.esri.com/t5/python-questions/copy-features-recieveing-catch-all-error-message/m-p/60787#M4871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;duh, forgive me -&amp;nbsp; blatant error I didn't see:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;set your workspace env variable as such:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(or 1 line):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = "C:/Temp"&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Oct 2012 20:18:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copy-features-recieveing-catch-all-error-message/m-p/60787#M4871</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2012-10-16T20:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Features - Recieveing Catch All Error Message</title>
      <link>https://community.esri.com/t5/python-questions/copy-features-recieveing-catch-all-error-message/m-p/60788#M4872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I can't believe I missed that also, Thanks! That did the trick!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Oct 2012 20:23:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copy-features-recieveing-catch-all-error-message/m-p/60788#M4872</guid>
      <dc:creator>RachelAlbritton1</dc:creator>
      <dc:date>2012-10-16T20:23:27Z</dc:date>
    </item>
  </channel>
</rss>

