I have encountered two problems when working with script tools in ArcGIS 10.4.1.5686:
I added a script tool to a toolbox and define an input parameter of type FeatureLayer. I then opened the tool in ArcMap and dragged one of my layers from the table of contents into the parameter input box. An error sign appeared by the tool parameter saying "Dataset soandso does not exist or is not supported", which is not true. It seems the feature layer parameter behaves as a an input box for type FeatureClass.
Another problem was with an output parameter. I created an output parameter of type FeatureClass and set its direction to "Output". When I run the tool, the output was produced but it is not added to the map document (Add output of geoprocessing operations to display is checked) and the result object suggests the output is a table and not a feature class. I can see the resulting feature class in catalog window OK.
Have you experienced anything like this?
Below is preview of result and the script.
import arcpy def copy_feature_layer_as_feature_class(in_fclr, out_fc): out = arcpy.management.CopyFeatures(in_fclr, out_fc).getOutput(0) return out if __name__ == "__main__": in_feature_layer = arcpy.GetParameter(0) out_feature_class = arcpy.GetParameter(1) fc_copy = copy_feature_layer_as_feature_class(in_feature_layer, out_feature_class) arcpy.SetParameter(1, fc_copy)