Skip to main content
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 ...
Ratnanil's user avatar
  • 1,033
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 ...
mikewatt's user avatar
  • 5,188
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 ...
user2856's user avatar
  • 69.6k
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 ...
PolyGeo's user avatar
  • 65.4k
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", ...
Mark Bryant's user avatar
  • 1,445
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). ...
Midavalo's user avatar
  • 29.9k
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 ...
Midavalo's user avatar
  • 29.9k
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.
Nacho Moreno's user avatar
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 ...
Michael Stimson's user avatar
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 ...
KHibma's user avatar
  • 17k
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 ...
Hayden Wilson's user avatar
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 ...
mmoore's user avatar
  • 1,011
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, ...
Bera's user avatar
  • 77.8k
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 ...
Aaron's user avatar
  • 51.8k
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 ...
Kadir Şahbaz's user avatar
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 ....
Midavalo's user avatar
  • 29.9k
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] # ...
Paul's user avatar
  • 11.6k
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 ...
mikewatt's user avatar
  • 5,188
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 ...
Midavalo's user avatar
  • 29.9k
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, ...
Hanne's user avatar
  • 56
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 ...
fatih_dur's user avatar
  • 5,013
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: ...
Carlos MSF's user avatar
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 ...
user2856's user avatar
  • 69.6k
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): [....
evod's user avatar
  • 333
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 ...
Hornbydd's user avatar
  • 44.6k
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 ...
fatih_dur's user avatar
  • 5,013
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:
FelixIP's user avatar
  • 23.3k
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 ...
Keggering's user avatar
  • 1,137
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 ...
PolyGeo's user avatar
  • 65.4k
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 ...
fatih_dur's user avatar
  • 5,013

Only top scored, non community-wiki answers of a minimum length are eligible