1

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", "")

1 Answer 1

3

You should be able to change the data type for the parameter to Feature Layer instead of Feature 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.

3
  • That did not work....btw Evil...how did you "re-format" my original post so the scrypt looks better/correct? And how do I do that myself going forward?
    – Nebula93
    Commented Sep 4, 2015 at 18:10
  • 1
    You changed the type in the script tool properties? Did it save them? It's been quite a while since I've used script tools (Python Toolboxes rock!), but I don't remember having to do anything special once the type was set. For your formatting questions: take a look at How do I format my posts using Markdown or HTML? Commented Sep 4, 2015 at 18:14
  • 1
    @Nebula93 This answer sounds right to me. Perhaps you can include graphics of your parameter settings and tool dialog in your question to show that/how it does not work.
    – PolyGeo
    Commented Sep 4, 2015 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.