9
votes
Accepted
Python toolbox documentation from within pyt file
This was bothering me probably more than it should have, and after getting to know python a little bit I've found that the problem is pretty easy to solve. Since I'm mostly an R user, these lines of ...
8
votes
Accepted
Packaging third-party libraries with Python Toolbox of ArcPy?
With pure Python packages you can simply place their module folders (cloned from git or wherever) into the same folder as your script files, and then in the properties for your tool check the box to ...
7
votes
Accepted
Python Toolbox - Only update parameter when specific parameter changes
The "arcpy way ™" is to check if parameters[0].altered and not parameters[0].hasBeenValidated:
According to the documentation:
altered
altered is true if the value of a parameter is ...
6
votes
Accepted
arcpy.GetParameterAsText not passing arguments to script?
The code that you have presented is for a Python Toolbox (*.pyt) for which you need to use the Parameter class.
GetParameter() and GetParameterAsText() are only used with Python Script tools in ...
6
votes
Accepted
Grouping Parameters in Python Toolbox of ArcGIS Pro
Add a category to the parameters that you want to group.
For example
screen = arcpy.Parameter(
displayName="Ghostscript 'screen' Compression",
name="gsCompress_screen",
...
5
votes
Renaming layer in a TOC using a tool within Python Toolbox
You haven't posted your full Python Toolbox pyt, so unsure whether you've got something in the Toolbox class that might be causing you issues, but your code above works fine for me (once completed). ...
5
votes
Referencing a compiled help file (CHM) from a python toolbox (PYT)
In a Python Toolbox you can create help for the side pane by editing the Item Description for the tool. To do this you can right-click on the tool in your toolbox
Click Item Description which will ...
5
votes
Defining parameter descriptions for Python Toolbox help?
You only need to click on the edit metadata of the tool you will see that for each parameter you can easily edit the messages to display.
5
votes
Accepted
Checking which application Python toolbox was launched from?
Based on https://stackoverflow.com/questions/404744/determining-application-path-in-a-python-exe-generated-by-pyinstaller I wrote a little script, added it to a toolbox and executed in ArcMap and ...
5
votes
Accepted
Capturing Encrypted String from ESRI Python Toolbox Parameter
You can't use the encrypted string parameter to do what you're trying to do. Encrypted string is for Esri components that accept an encrypted strings. Basically for passing a password to an enterprise ...
5
votes
arcpy.GetParameterAsText not passing arguments to script?
Using the answer from @PolyGeo my corrected code is as follows:
import arcpy
class Toolbox(object):
def __init__(self):
"""Define the toolbox (the name of the toolbox is the name of the
...
5
votes
Accepted
Python Toolbox Value Table Parameter - getting separate outputs for different column inputs
I was calling my parameter with the line:
target_elements = params[0].valueAsText
I needed to be calling the parameter as a value:
target_elements = params[0].value
This gave a list of values and ...
5
votes
Accepted
Error: local variable referenced before assignment in ArcPy
It is telling you that the variable shape has not been assigned/created when you are trying to use it. So your code probably never reach this line: shape= fd +"\\"+i+"\\"+entry, ...
5
votes
Accepted
For loop for access to a directory files in ArcPy
Here are four approaches. The first uses the arcpy Walk function. The second, third, and fourth approaches use built-in python modules. The fourth approach is the one you provided.
Here are the time ...
5
votes
Accepted
Generating multiple page reports (Page Per Report) using ArcGIS Pro & Python
There is a missing part in example 3. self is unknown. As @KHibma stated, it might be a part of a bigger project, probably a Python tool.
I am not able to test right now, but removing selfs and ...
4
votes
Accepted
Cannot make feature layer in python toolbox using parameters
Without debugging your entire script, you haven't told your python toolbox to retrieve the parameter value.
boxNumber = parameters[0]
buildingType = parameters[1]
You need to suffix these with ....
4
votes
Accepted
Access python toolbox input parameter - list of excel files
You're on the right track. From the value object returned by .values, you need to extract the actual value. There's a few ways that can be done:
excelList = [v.value for v in parameters[0].values] # ...
4
votes
Python Toolbox parameters set up error: Value is Required
Unfortunately the "parameterType" is a read-only property, so you can't just change that parameter from "Required" to "Optional".
You can work around this by setting it to "Optional", then performing ...
4
votes
Accepted
How to display a progress bar in an arcpy python toolbox?
To see the progress dialog as seen in the linked Q&A you need to have self.canRunInBackground = False set in your PYT code. This will force your tool to run in the foreground with that dialog ...
4
votes
Accepted
Arcpy Toolbox sending and error message in specific condition
setErrorMessage should be called from updateMessages, not from updateParameters. Check out example 3 on http://pro.arcgis.com/en/pro-app/arcpy/classes/parameter.htm
I don't have your data to test on, ...
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 ...
4
votes
Accepted
CalculateField_management, python Toolbox
In the CalculateField_management you are giving the desc.baseName as the expression parameter. It assumes the value of that variable is the name of a function that is not defined.
This should work:
...
4
votes
Licensing Issues while writing Community Project using ArcPy?
If you're writing tools/code that only require a basic license to replicate functionality available with an advanced license then go nuts, people have been doing that for years. For example, the ...
4
votes
Unable to load layers created with Processing Toolbox PyQGIS 3
It would help if you could create a minimal version of your script.
I observed that output layers from sinks are automatically added to the project, e.g.:
def initAlgorithm(self, config=None):
[....
4
votes
Accepted
FeatureClass error message when running ArcGIS Python tool
There are several problems with your code. You create a variable called tmpfile and then you overwrite it so destroying the original value. Your variable is a feature class. If you read the help file ...
4
votes
Accepted
Updating ValueTable parameter of ArcPy Python Toolbox tool
The gist of your answer can be found in Python Toolbox - Only update parameter when specific parameter changes. You need to use altered and hasBeenValidated properties of arcpy.Parameter.
In this ...
4
votes
Data Type that can be used to select Desktop as a folder in ArcGIS Python Toolbox (ArcGIS Desktop: ArcMap 10.6)
Made it a minute ago, using Folder as type of parameter:
4
votes
Grouping Parameters in Python Toolbox of ArcGIS Pro
I used @Mark Bryant's "category" answer/suggestion, coupled with using a "multiValue" parameter-type, instead of a bunch of individual parameter types. Screenshot shows the updated ...
4
votes
Accepted
Getting new parameter after Python Toolbox gets executed
In What is a Python toolbox? it says:
Python toolboxes are geoprocessing toolboxes that are created entirely
in Python. A Python toolbox and the tools contained within look, act,
and work just like ...
4
votes
Using Python Toolbox Parameters
This is the expected behaviour, which is similar to Dissolve or Summary Statistics tools. You can set one dependency to the extract fields of a table (i.e., feature class as well). If you change ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
python-toolbox × 325arcpy × 296
parameters × 61
arcgis-pro × 57
arcgis-10.2 × 37
arcgis-desktop × 29
arcgis-10.1 × 26
arcmap × 25
arcgis-10.3 × 23
python × 22
geoprocessing-service × 18
tool-validation × 15
arcgis-server × 14
arcgis-10.4 × 14
value-table × 14
python-script-tool × 12
multi-values × 11
python-2.7 × 9
arctoolbox × 8
coordinate-system × 5
geoprocessing × 5
cursor × 5
spatial-analyst × 4
fields-attributes × 4
arcgis-10.5 × 4