Hello,
Been doing a lot of python coding lately and starting to get into the weeds of the script tool. I notice that the Data Type of parameters allow feature layer or feature class, but doesn't allow the flexibility of both. Any suggestions on how to get our tools to allow them? I don't want to force them to utilize feature layers, but sometimes it is easier to drag and drop from the contents instead of having to find them in the file folders.
Andrew
Feature Layer parameters accept the data source directly as well. I use it all the time.
Just depending on what precisely you're doing, it may require extra work to get exactly what you want.
A Feature Class can only take feature classes via a path, but gives you guaranteed access to the data definition (fields, indices, attribute rules etc.).
A Feature Layer can take a feature class by path or a layer from the current map. You can't always edit the structure of your data but you can edit its features, and the user can pass in a subset of the full data.
A Feature Set can take all of the above plus arbitrary feature data from any source. But it's even less likely that you can modify the data's structure.
In short: as you go from FC to FL to FS it becomes harder for the user to specify what exact data is edited but the script has an easier time modifying the data. I usually go with Feature Layers if I don't have a specific use case but it's up to you.
(Note that Table, Table View and Record Set are the non-spatial types of their respective parameters. This doesn't stop you from passing in spatial data but you lose the guarantee that you can work with the data's coordinate system, geometry data etc.).
At the end of the day, it doesn't really matter what you put the parameter as. I frequently use folder and string parameters as inputs that are later turned into Featureclass objects.
You can build a dictionary on initialization that maps strings to features, or folders to databases, etc.
If you are going to have parameters set up like that, be careful to validate them before you do anything though.