Working with multivalue parameters in a custom toolbox

2981
1
Jump to solution
12-16-2015 02:13 AM
BenjaminSimpson
New Contributor III

Hi,

I am currently creating a custom toolbox which will run a script to append tables and feature classes from one personal geodatabase to another. Abit of background about these personal GDBs; they all have the exact same format in terms of the number of feature classes and tables, their objects names and the structure/type of tables/feature classes. You could think of these personal GDBs as regional databases. What I need to do is merge several of these GDBs into one GDB. What I am currently unsure about how to code is I want to create a python script to automate this process (which working on one GDB at a time is fine), specifically to run through multiple GDBs at a time.

So in my script I have a variable (Import_SIMCAT) which holds a list of the GDBs selected to be appended to, and I have a variable (Export_SIMCAT) which holds the GDBs being appended from. To make things less straight forward, I have a varying number of GDBs being appended/merged together, so one GDB may have only one other GDB being appended to it while another may have 5 GDBs being appended to it. The question I have is how in my script can I get my code to identify which GDBs need to be appended to which?

For example, lets say that I have 10 GDBs being appended to 4 GDBs. In the variable Import_SIMCAT I would have GDBs A,B,C,D while in variable Export_SIMCAT I would have GDBs E,F,G,H,I,J,K,L,M,N. I would want GDB E,F and G to be appended to GDB A, while GDB H to be appended to GDB B, while GDBs I,J,K and L to be appended to GDB C and finally GDBs M and N to be appended to GDB D.

I dont know if it is possible to make it so that the user can identify which GDBs are getting appended to which. At the moment I only know how to loop through the selected GDBs by using their index position within the list variable they are stored in. But that process doesnt work when I have different number of GDBs being appended.

I hope that makes sence. If it helps I can put a copy of my current script on here but as it currently stands it is very unformed and only creates variables for the two different parameters, splits them up into lists and removes the unwanted single quotes.

Thanks in advance for any help and advice anyone can provide on this topic.

Ben.

0 Kudos
1 Solution

Accepted Solutions
FreddieGibson
Occasional Contributor III

The easiest option would be to keep your tool simple. Allow the user to only select a single geodatabase in your first parameter and whatever geodatabase they select in the second parameter will be appended into it. If they want to do multiple geodatabases then they'll need to run the tool multiple times.

If you want the tool to work with multiple input and append geodatabases where everything isn't equal then you'll need to present the tool in a manner that allows you to determine what goes where. I would suggest maybe using a value table parameter where you can have the user specify the geodatabase that you should append into. This is most likely going to involve writing up a custom tool validator class to handle the values in the value table.

Defining parameters in a Python toolbox

http://desktop.arcgis.com/en/desktop/latest/analyze/creating-tools/defining-parameters-in-a-python-t...

View solution in original post

1 Reply
FreddieGibson
Occasional Contributor III

The easiest option would be to keep your tool simple. Allow the user to only select a single geodatabase in your first parameter and whatever geodatabase they select in the second parameter will be appended into it. If they want to do multiple geodatabases then they'll need to run the tool multiple times.

If you want the tool to work with multiple input and append geodatabases where everything isn't equal then you'll need to present the tool in a manner that allows you to determine what goes where. I would suggest maybe using a value table parameter where you can have the user specify the geodatabase that you should append into. This is most likely going to involve writing up a custom tool validator class to handle the values in the value table.

Defining parameters in a Python toolbox

http://desktop.arcgis.com/en/desktop/latest/analyze/creating-tools/defining-parameters-in-a-python-t...