6
votes
Accepted
Controlling Categories in Script Validation Tools - Expanding Groups By Default
This isn't possible in python, but you can by using a custom stylesheet.
Copy "C:\Program Files (x86)\ArcGIS\Desktop10.2\ArcToolbox\Stylesheets\MdDlgContent.xsl" to the same folder as your script.
...
6
votes
Accepted
How to only ask for a input if checkmark has been checked? (arcgis script tool)
A general introduction: to change how a tool's "interface" behaves, you can go into the validation tab of the script. this is done by right clicking on the script in the catalog window -> select ...
5
votes
Accepted
Create default ArcToolbox parameter with current folder location of ArcToolbox .tbx
What you're looking for is the __file__ variable, which in this case will contain a path such as:
C:\Users\users\Documents\ArcGIS\Toolbox.tbx#Script.InitializeParameters.py
So just do a pathname = ...
5
votes
Accepted
Maintaining sorted unique values in value table of ArcGIS Pro Python script tool validation?
You don't have to make a value for the parameter by loading it from a string. It's enough just to do the assignment:
def updateParameters(self):
self.params[0].value = sorted(list(set(self.params[0]...
4
votes
Accepted
Non-existent polygon inside polgyon
Interesting shapefile! I had trouble cleaning it with standard tools such as Geometry Checker and GRASS's v.clean. But an alternative method is to:
Convert your polygons to lines:
Vector > ...
4
votes
Accepted
Tool validation - setting error message
If you use altered method of the Parameter object, your simple validation routine should work fine, e.g.,
def updateMessages(self):
"""Modify the messages created by internal ...
3
votes
Accepted
ArcPy Tool Validator error with defined parameter value
The problem is in your code:
def updateParameters(self):
if self.params[0].value == "Digital Map":
self.params[1].value = "No scale required"
if self.params[0].value ==...
3
votes
Accepted
Creating drop down of derived fields from CSV using ArcPy?
It is definitely possible. You would need to use script tool validation class.
Read the .csv headers (can be done with csv or pandas, for instance).
With csv:
import csv
csv.DictReader(open(r"C:\...
3
votes
Accepted
Deriving input based on other parameters in Python script tool?
You want to look into Script Tool Validation - see Understanding validation in script tools and Customizing script tool behavior with Validation
Validation allows you to pass some arcpy code when ...
3
votes
Using OS module in the updateParameters of Python Toolbox
The os.path methods operate on strings. You are passing a Value object not a string to os.path.dirname. Use parameters[0].valueAsText or parameters[0].value.value instead of parameters[0].value.
i.e....
2
votes
Accepted
Select All in the Python script tool doesn't work
I believe the issue is with these lines:
if self.params[2].value not in self.params[2].filter.list:
self.params[2].value = self.params[2].filter.list[0]
It is trying to protect the input by ...
2
votes
Accepted
Forcing Python Script Tool Parameter Input Field to Begin at Specific Folder?
Since the user will always select a file from the same folder, then you don't need to have the file browser involved. This solution won't set a default directory; instead, it will populate a drop-down ...
2
votes
How to Prevent Final (Unnecessary) Selection Box in Script Tool Input Parameters via Validation Script?
This is not the answer, but I thought I'll share my experience with parameter type ANY. @Luke statement is correct, it can't have Value List filter, but it can contain a list of values.
With some ...
2
votes
Accepted
Getting simple ArcGIS Python toolbox parameters to be enabled or disabled on load
execute is called when you click the run button, not when the tool loads.
Set params 1-6 enabled = False in getParameterInfo initially.
getParameterInfo is called automatically, don't call it yourself
...
2
votes
Accepted
Python Toolbox updateMessages - Remember message from an earlier validation?
The issue is with how to track changes when internal validation is run. Think about your logic; you select a layer and it checks if there are less than 100 features, but it only does that if the ...
2
votes
Python Script Tool with validation not opening in ArcGIS Pro
I think that it is the two extra spaces of indentation before your first return that is causing the problem.
Try this instead of the code that you have presented:
def initializeParameters(self):
...
1
vote
Accepted
Getting zmin zmax of a raster parameter in a tool validation in ArcGIS Desktop 10.7 toolbox Python script
You were almost there! Firstly ensure your parameters are their correct data type as shown below:
The correct code in the validation function updateParameters would be:
def updateParameters(self):
...
1
vote
ArcGIS Pro Script Tool Validation Not Updating Values in Tool
Assuming you want to set defaults, i.e "pre-filled", just set them directly in getParameterInfo
e.g.
def getParameterInfo(self):
#Define parameter definitions
# First parameter
param0 = ...
1
vote
List fields in parameters from Fc list in script validation using arcpy in arcgis
There could be two issues here:
This line: for field in arcpy.ListFields(lyr.dataSource): this is returning a Field Object which you are adding to list which you then feed into your param[3]. I'm ...
1
vote
Accepted
How to Prevent Final (Unnecessary) Selection Box in Script Tool Input Parameters via Validation Script?
For some reason there was a "schema.ini" file in the folder with all the other .csvs. Not sure why it was there. I certainly never created it (knowingly).
Once I deleted it the extra box has ...
1
vote
Accepted
Toggle field in custom Arcpy script
Try this:
def updateParameters(self):
if self.params[0].value and self.params[0].altered:
self.params[1].enabled = True
self.params[2].enabled = True
self.params[3]....
1
vote
Toggle field in custom Arcpy script
With == you are asking if the enabled parameter is equal to True or False which makes no sense.
What you want to be doing is assigning the parameter True or False, in that case you use a single =.
1
vote
Accepted
Validating user input against a range using tool validator in arcpy script?
Below is the code you need in updateMessages() :
It would check if an alpha numeric code is 4 characters long and a numeric code must not be greater than 9999. The key function is isdigit() this ...
1
vote
Accepted
ArcGIS Toolbox Python Script Validation: extracting field names from a multi-value list of feature classes
This validation works:
def updateParameters(self):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
...
1
vote
Accepted
List layers in dataframe as parameters in script validation
I think this line is wrong:
layerList = [lyr.name for lyr in arcpy.mapping.ListLayers(mxd, self.params[0].value) if not lyr.isGroupLayer]
A ListLayers() requires an mxd or a dataframe, not both. So ...
1
vote
Accepted
ArcGIS Tools Script Validation...filter list from domain values
There doesn't seem to be a way to convert the domain values to a list directly. However, as an intermediate step, you could convert your domain to a table using the DomainToTable tool, then convert ...
1
vote
Accepted
ArcGIS Tool Script Validation...browser window default location for multivalue option box
Unfortunately, you won't be able to specify the default folder when browsing for the files.
I had a similar problem some years ago and was forced to work around this using two parameters. The first ...
1
vote
Performing operations on Python Script tool startup
If you want to carry any state from one run of the tool to the next then I think you may need to save/read that state to/from a table or text file.
I have done this when wanting to use a Python AddIn ...
1
vote
Editing validation code for Python script tool in ArcGIS Pro using IDLE?
A workaround for this situation, which I have not been able to resolve, is to re-write the tool so that it resides in a Python Toolbox rather than being a Python script tool in a standard toolbox.
...
1
vote
Problem getting value from arcpy script tool with validation code driven drop-down: code window popup on tool execution
A couple of things might be happening that may slow things down, or their may be ways to speed it up. Although, validation in my experience is always slow.
For one, since you are using ArcPy 10.1, ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
tool-validation × 88arcpy × 81
python-script-tool × 47
parameters × 20
python-toolbox × 15
arcgis-desktop × 13
arcgis-10.2 × 11
arcgis-10.1 × 8
arcgis-pro × 8
python × 7
arcgis-10.3 × 5
arcmap × 4
arcgis-10.0 × 4
modelbuilder × 3
python-2.7 × 3
choice-list × 3
raster × 2
shapefile × 2
fields-attributes × 2
geoprocessing × 2
value-list × 2
qgis × 1
coordinate-system × 1
polygon × 1
arcgis-server × 1