Select to view content in your preferred language

Unknown number of parameters in script

460
3
06-21-2023 06:29 AM
MartinPorteš
Occasional Contributor

I'm creating a set of scripts with tens of input parameters. First 5 are paths to databases, network datasets etc. Next 3 specify what type of analysis should be calculated. So first 8 parameters are set and defined. Additionally parameters  8-40 (for now) are optional booleans which specify what region or district should be calculated. 

The idea is, that the script reads definition in database, where it is specified what should happen for said region/district. Therefore user adds new optional parametr as boolean dynamically with the same name as specified in DB. 

Is there a clean solution to iterate number of parameters, read their name and value and then run analysis based on what is preapred in DB?

I need not to do arcpy.GetParameterAsText(xx), because that would force change of script. I also need to know the parameter name to find correct definition in DB. 

Thank you for any ideas!

Martin

 

Tags (1)
0 Kudos
3 Replies
AlfredBaldenweck
MVP Regular Contributor

Is it possible to instead have a few multivalue parameters whose options change based on previous answers?

40 parameters is a LOT.

Like, are you basically asking the same questions over and over again for each region/district, and that's why you need so many?

If that's the case, I'd look into value table parameters, as well as play around with tool validation

0 Kudos
MartinPorteš
Occasional Contributor

Hi, I don't think so. Or I don't fully understand to your idea. 

I know that 40 is extreme, but the user is able to choose predefined tasks (so in the 40 "regions" are at the moment 15 analysis). So grouping is possible, but I need to clearly know what region should be calculated. Problem is, that the amount of analysis can grow and the same thing can happen to the regions. 

I want to allow the user to prepare new region, but not necessary to go in script and add new arcpy.GetParamAsText(46)...
I will look into value table and into tool valudations. I always ignored theese, since I struggled to understand the composition/definition of them. 

Anyway, thank you for the idea.

Martin

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

Value tables are kind of a pain, but they can definitely simplify your input a lot.

AlfredBaldenweck_0-1687369975901.pngAlfredBaldenweck_1-1687370053245.png

I wanted to give you a tool validation example on filtering, but it's giving me issues today.

It's hard to say without seeing your tool, but I think they're worth investigating

0 Kudos