1

I am new to ModelBuilder.

I am running a python script from ModelBuilder that requires as it's parameters a table view and specific field names from that tableview. Essentially the script is looking for information from specific fields without knowing what the user may call the fields.

For example, the script needs an 'address' field and the user may have identified their address field as 'street' in their table.

I am wanting a dropdown field populated by the tableview that the user can select the correct field from and pass that field name to the script as a parameter. I have tried using the Get Field Values tool and arcpy.GetParameterAsText(1) returns the value of the field but what I need is the field name itself.

I was thinking there should be a way to create a list and populate it with something like:

fieldList = []
fields = arcpy.ListFields(tablePath)

but I have no idea how I would do this in ModelBuilder and be able to use that list to populate and parameter list the user could then use to select the correct field.

2

For a script tool, you could do something like this:

enter image description here

To create a fieldList from the fields that the user has selected, try this in your script:

  • fieldList = Attributes.split(";")
  • You are a lifesaver Nxau!! I only had time to run an simple initial test, but it looks like this will work perfectly for me.. many thanks!!! – pbaldridge Mar 7 '16 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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