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,083
8 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
  • 973
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.1k
6 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
  • 65.3k
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,437
5 votes

Private functions in Python Toolbox

Of course you can split your code out into functions. Don't bother with private methods, they aren't really private and they just make your code harder to read. Note that the convention for private ...
user2856's user avatar
  • 65.3k
5 votes
Accepted

ArcPy Calculate Null Values to Zero in Multiple Fields

you can work on more than one fiel at the time, and use some list comprehension to go through your row with arcpy.da.UpdateCursor(target, ("ELEM_STUD","second_field","thirdfield") ) as cursor: ...
radouxju's user avatar
  • 49.6k
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

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.7k
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.7k
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
  • 16.7k
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,013
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
  • 71.2k
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.6k
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

ListFields not working from Python Toolbox

When I tested your script, it returns myLayer as geoprocessing parameter object object at... and its uninterpreted value is a string, therefore your IOError (i.e., ListField expects a file location or ...
fatih_dur's user avatar
  • 4,983
4 votes
Accepted

Do ArcGIS Pro tasks support Python Toolbox tools which operate on Map Frames?

*.PYT toolboxes are not supported for tasks in ArcGIS Pro 1.0 and 1.1. However, they have been supported since ArcGIS Pro 1.2. As a workaround try to insert your tool into a geoprocessing model, and ...
Skipper's user avatar
  • 156
4 votes
Accepted

Removing functions from Python Toolbox Template?

My understanding is that ArcToolbox is a window within ArcMap, ArcCatalog and the 3D applications, after earlier being a separate application. As such I think that it is quite independent of any ...
PolyGeo's user avatar
  • 65.1k
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.7k
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,083
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.7k
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
  • 4,983
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
  • 65.3k
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
  • 43.2k
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
  • 4,983

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