Model Parameter ideas for user selecting optional pathways/outputs

1554
5
Jump to solution
03-15-2013 12:03 PM
ZacharyHart
Regular Contributor
My ideal would be a radio button that has a 'yes/no' option. But I know that's not going to happen.
I don't think the background of this particular model matters for the sake of this discussion, but if someone wants to see it i'll post a graphic. Basically the GP task extracts interactively selects the data and makes it available for download via the Extract Data to Zip file script. I'd like there to be an option of merging the data before the extraction. I know how to get the data to merge, but only as a separate model, so i'm looking to somehow expose a user input parameter/value which would then cause the model to merge the data as an alternative.

Any suggestions within the model builder environment?
Reply
0 Kudos
1 Solution

Accepted Solutions
curtvprice
MVP Esteemed Contributor
Thanks for the responses.  Can anyone provide an example of just testing whether a parameter exists?


When you use GetParameterAsText, when no value was provided, it comes across as an empty string.

# test if the third parameter was set if arcpy.GetParameterAsText(2) == "":   do this else:   do that


If you have a checkbox parameter (Boolean) you can do this:

# test if the third parameter was checked # Booleans come across as the string "true" or "false" if arcpy.GetParameterAsText(2) == "true":   do this else:   do that

View solution in original post

Reply
0 Kudos
5 Replies
EricStipe
New Contributor III
I believe you could use a "Calculate  Value" before the extraction, and write a if/elif in it. Then, you could use the expression as a parameter (or setting a string as a parameter, and inline variable it as the expression) and it will appear in the dialogue box when the model is run. From here, depending on how you write the function you could have the user type "Yes" or "No" and work from there, I think.

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//0017000000v8000000
Reply
0 Kudos
curtvprice
MVP Esteemed Contributor
There's a great set of ArcGIS Blog posts on this topic that really opened my eyes to some of the more advanced capabilities of ModelBuilder. Parts 1 and 2 directly deal with your question on how to branch models.

ArcGIS Blog: If You Are Stuck At "If" (5 parts)
Part 1
Part 2
Part 3
Part 4
Part 5
Reply
0 Kudos
ZacharyHart
Regular Contributor
Thanks for the responses. I'm kind of leaning towards the arcpy solution, but it seems every example uses an arcpy.function. Can anyone provide an example of just testing whether a parameter exists? I'm getting better with arcpy, but I'm still in need of examples to jump start the process.
Reply
0 Kudos
curtvprice
MVP Esteemed Contributor
Thanks for the responses.  Can anyone provide an example of just testing whether a parameter exists?


When you use GetParameterAsText, when no value was provided, it comes across as an empty string.

# test if the third parameter was set if arcpy.GetParameterAsText(2) == "":   do this else:   do that


If you have a checkbox parameter (Boolean) you can do this:

# test if the third parameter was checked # Booleans come across as the string "true" or "false" if arcpy.GetParameterAsText(2) == "true":   do this else:   do that

View solution in original post

Reply
0 Kudos
ZacharyHart
Regular Contributor
Curt, I just wanted to circle back to this and provide a thanks. I got really busy after I posted this and just didn't get a chance to reply.
I feel pretty dumb for not knowing exactly what the Boolean parameter does. My biggest challenge was incorporating this into my model I'm comfortable with the if/else within python, but building that into my model wasn't working for me, so I ended up attempting to convert the model all into python. the problem then is that the model essentially has linear pathways and the derived/intermediate data need to all be defined uniquely within python and that's where I ran into problems. I'm not exactly sure where this leaves me, but you did answer my question at least!
Reply
0 Kudos