Python Toolbox Help

345
3
Jump to solution
09-09-2020 05:08 AM
MarkBinder
Occasional Contributor

I am trying to create a Python toolbox that will copy feature classes from an enterprise geodatabase and put them in a local file geodatabase. 

I have the first parameter set up as a multivalue where the user can input the feature classes to copy. I would like to give the user the option to save the feature class names to a file for future use. I am able to save the list of layers to a text file. 

How can I load the feature classes from the text file into the script? Is it as simple as making the parameter.value equal to the saved text?

0 Kudos
1 Solution

Accepted Solutions
MarkBinder
Occasional Contributor

Exporting the layers multivalue parameter to a text file works great. I am able to use that same text file to populate the layers multivalue parameter and then I can remove any layers that I don't want. 

View solution in original post

3 Replies
DanPatterson
MVP Esteemed Contributor

You would have to read the file, so the parameter would be of type 'file'.  Then you have to parse the file by line, check that each path is valid, then define the multivalue list so that people could remove/add to what was in the file.

Do you have the script working without this extra layer of complication?


... sort of retired...
0 Kudos
MarkBinder
Occasional Contributor

I have the script working right now; it just takes layers and copies them to a file geodatabase. I already created the option to save the list of layers to a text file; this consists of a check box and an input for where to save the text file.

What I would like to do is have something similar for retrieving the list of layers from the text file. So I would have a checkbox to import the layers from the text file and a parameter to designate the text file.

I have been able to save the list of layers by saving the parameter.valueAsText to the text file. I am trying to set it so once the user checks the box and designates a text file and it sets the parameter.value equal to the text in the file.

I tested it with layers from a geodatabase and the layers parameter populated all of the layers from the text file. What I need to do is get it to work with layers in an sde connection.

0 Kudos
MarkBinder
Occasional Contributor

Exporting the layers multivalue parameter to a text file works great. I am able to use that same text file to populate the layers multivalue parameter and then I can remove any layers that I don't want.