Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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", "")
share|improve this question

1 Answer 1

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.

share|improve this answer
    
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 14 hours ago
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? –  Evil Genius 14 hours ago
    
@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 12 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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