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
Make Feature Layer (Data Management)—ArcGIS Pro | Documentation
It would probably work if you created a *.lyrx file (a layer file) with a path.
Well, just tried to run the same code in python3 and it works...
Layer properties—ArcGIS Pro | Documentation would be a good check prior to using a feature layer.
python3? all pro tools have to use python 3
It works on python27 with arcgis 10.6
I believe you need to use Copy management to create a shapefile or feature class.
Make Feature Layer (Data Management)
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.