How to add multi parameters, looping through each one in order to complete?

2349
3
02-27-2018 08:23 AM
JonathanHallam2
New Contributor

Hi,

For the script in picture below that is exported from a model builder running through the erase tool multiple times in order. 

I would like to add a multi value parameter which I think I have found to do in parameter tab in properties of script tool. 

How can I get all the inputted feature classes to be looped through erase tool in order added, as the current tool does, saves editing the script or model

Multi Erase Scrip

0 Kudos
3 Replies
JonathanQuinn
Esri Notable Contributor

You need to use arcpy.GetParameter and set an input parameter as a multi-value parameter.

import arcpy
myList = arcpy.GetParameter(0)
for thing in myList:    
    arcpy.AddMessage(thing)‍‍‍‍‍‍‍‍‍

arcpy.GetParameter lets you access myList as a list object instead of using arcpy.GetParameterAsText which sets it as a string object and you needing to split it yourself.

Set the input as a multi-value input which will let you add items to a list:

The loop simply prints the values of the myList object, so that's the business section of your script:

I'd also suggest you avoid overiding built-in types like list.

MicahBabinski
Occasional Contributor III

Hey Jonathan,

Can you describe what you are trying to do? What are your inputs, outputs, and processes? Who will run this process? That info would help us figure out the best way to structure your script.

Micah

0 Kudos
JonathanHallam2
New Contributor

Hi Micah, 

I am trying to set up a tool script that runs a multi erase function. The original purpose is to erase planning restriction (inc flood zones, SSSI's, Conservation areas) data on company parcel data to see what land land is left that has no restrictions. I would like to have an output after every erase. I am trying to create a script for this to be run with different data inputs, not necessarily for restrictions, for different projects. The output would be land parcel file after erase features have been erased, at least one output but would like an output after every erase. The processes is erase analysis tool, I created a string of these in a row in model builder with parcel layer first input and then each output becomes input for next erase. The order is key particularly with restrictions as some are more important that others and if outputs created after each erase it creates an audit to go back through if needed. The people running this would be geospatial staff in my department who need it, mainly my analytics team, for mainly site selection analysis specifying suitable available land for customer interests.  

0 Kudos