More

Adding drop down option for layers in Python script tool?


I've code that will add fields to feature classes. I've parameterized the script so the user can navigate to the location of the feature classes to be edited.

If the feature class is already open and in my data frame I want the option for the drop down to pick feature classes that are already open rather than having to navigate to the location of the files.

Does that require code being added to my script or is that something I can do in the script properties?

My code looks like this currently.

import arcpy fc = arcpy.GetParametersAsText(0) # Process: Add Field arcpy.AddField_management(fc, "DATE_MOD", "DATE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "") # Process: Add Field arcpy.AddField_management(fc, "DATE_ADDED", "DATE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "") # Process: Add Field arcpy.AddField_management(fc, "MOD_BY", "TEXT", "", "", "50", "", "NULLABLE", "NON_REQUIRED", "") # Process: Add Field arcpy.AddField_management(fc, "ADDED_BY", "TEXT", "", "", "50", "", "NULLABLE", "NON_REQUIRED", "")

You should be able to change the data type for the parameter toFeature Layerinstead ofFeature Class.

That will give you a drop down list of all layers currently loaded in your map, as well as still allow feature classes to be specified manually (browsing to them).

Table View should work the same way, but for tables.