Im trying to create a shapefile with input from a featurelayer
it fails with:
WARNING: Failed to convert: MyLayer. ERROR 000210: Cannot create output c:\temp\Shapes\MyLayer.shp
Failed to execute (CopyFeatures).
fc = r"c:\connections\MyEditor@MyDb.sde\mydb.measurement.Line" arcpy.MakeFeatureLayer_management(fc,"MyLayer") print(arcpy.GetCount_management("MyLayer")) arcpy.FeatureClassToShapefile_conversion("MyLayer", "c:\\temp\\Shapes") #<-- This fails #If I in the FeatureClassToShapefile_conversion uses the featureclass instead of the featurlayer it works. arcpy.FeatureClassToShapefile_conversion(fc, "c:\\temp\\Shapes") #<-- This works
What can I be doing wrong? The count returns 420504 so the featuerlayer contains data
I suspect it can't find "MyLayer" since it doesn't know where it is, I don't think you "fc" plus "MyLayer" makes an actual layer file. It needs a workspace, then the layer name
It would probably work if you created a *.lyrx file (a layer file) with a path.
I believe you need to use Copy management to create a shapefile or feature class.
The temporary feature layer can be saved as a layer file using the Save To Layer File tool or can be saved as a new feature class using the Copy Features tool.