How to generate multivalue choice list (toolbox script) to clip only selected features?

4776
8
Jump to solution
09-26-2014 12:11 AM
JohannesBierer
Frequent Contributor

Any ideas, python scripts?

0 Kudos
1 Solution

Accepted Solutions
curtvprice
MVP Esteemed Contributor

Can you provide a little more detail? I'm guessing you want to present a dynamically generated list of checkboxes to the user. This would probably be a job for a Value Table parameter set up using a Python toolbox (pyt). Script tools in a tbx don't support value tables like this.

You could probably populate a filter values to select in validation code for a multi value of strings, but I don't know if that's really what you want and would be also kind of complicated to the tool user.

Sure you don't want to just present a SQL expression as a parameter and provide dialog documentation to guide the user to operate the select dialog that they already know how to use? (Sometimes less is more.)

View solution in original post

0 Kudos
8 Replies
curtvprice
MVP Esteemed Contributor

Can you provide a little more detail? I'm guessing you want to present a dynamically generated list of checkboxes to the user. This would probably be a job for a Value Table parameter set up using a Python toolbox (pyt). Script tools in a tbx don't support value tables like this.

You could probably populate a filter values to select in validation code for a multi value of strings, but I don't know if that's really what you want and would be also kind of complicated to the tool user.

Sure you don't want to just present a SQL expression as a parameter and provide dialog documentation to guide the user to operate the select dialog that they already know how to use? (Sometimes less is more.)

0 Kudos
JohannesBierer
Frequent Contributor

The idea is to clip about 50 Layer with a given polygon. Because not always these 50 are needed, the user should be able to check or uncheck certain layer?

0 Kudos
JamesCrandall
MVP Frequent Contributor

Is this a ESRI Add-in tool?  If so, ESRI has a sample of populating the ComboBox and then running the desired process on the selected item:

ArcGIS Help 10.1

0 Kudos
curtvprice
MVP Esteemed Contributor

Seems to me a generic multivalue list of layers would work for this, the user can delete inputs they don't want.

If this is a list of datasets in a folder, you could use tool validation to read the data in and populate as multi-value list of strings. Checkboxes are supported for them.

From a usability perspective, for a tool I would lean toward doing it as a regular multi value (a list of layers, not with checkboxes) because that is more consistent with tools the user is used to (i.e. Intersect, Union, Append, etc). Add ins are a kind of different paradigm so the checkboxes may make more sense if you do it that way.

JohannesBierer
Frequent Contributor

Thanks for your help. Unfortunately I can't generate Add-ins, because installations are forbidden 😞

So I tried this simple solution:

import arcpy

import os

input = arcpy.GetParameterAsText(0)

clipfeature = arcpy.GetParameterAsText(1)

output = arcpy.GetParameterAsText(2)

arcpy.env.workspace = output

inputSp = input.split(";")

for i in inputSp:

 

    arcpy.AddMessage(i)

    arcpy.Clip_analysis(i, clipfeature, i)

0 Kudos
JamesCrandall
MVP Frequent Contributor

Then you should mark Curtis' answer as the correct one because it better describes your situation and requirements to arrive at a solution.  Also, it's best if you post the current code version you are stuck at in your original post so the forum members can arrive at a solution much quicker rather than having to dig out what it is you are attempting -- I couldn't quite tell what you needed to accomplish and was the reason for my questions rather than posting an actual solution or sample.

Glad you figured it out.

0 Kudos
JohannesBierer
Frequent Contributor

James, there was no code I stucked with. The code was written after your suggestions 🙂

0 Kudos
curtvprice
MVP Esteemed Contributor

Thanks James, you're a peach.

0 Kudos