15 votes
Accepted

Choosing string from dropdown list rather than typing it into Python script tool?

There are a couple of ways to approach this: Create a list of filter values in the parameters property. Create the list in the validation script. I prefer the second route since you have more ...
  • 526
11 votes
Accepted

Can multiprocessing with arcpy be run in a script tool?

Yes, you can run multiprocessing child processes from a toolbox script. Below is some code to demonstrate in a Python Toolbox (*.pyt). There are a number of "gotchas". Some (but not all) will be ...
  • 58.7k
11 votes

Adding output parameter to Python script tool?

This was a simple question that had found difficult to answer. I searched through the Esri documentation, which is usually very thorough, but just overlooked it. I wanted to share my answer here in ...
  • 353
10 votes
Accepted

Using dot notation vs underscores when calling ArcPy functions?

Both are just different names for the same thing. You can see this by using the is operator: arcpy.na.CopyTraversedSourceFeatures is arcpy.CopyTraversedSourceFeatures_na will return: True Which ...
  • 1,702
9 votes
Accepted

ArcGIS Python Script Tool Field Name Drop Down?

Change the "Obtained from" property for the input to the shapefile parameter.
8 votes
Accepted

Setting input parameter to be float for Python script tool?

Your issue is arising due to the use of a comma as the decimal mark. It may help to understand that in your script you are not converting a double into a float, you are converting a string into a ...
  • 3,965
7 votes
Accepted

Does arcpy.GetParameterAsText() have a data type?

As the name GetParameterAsText() indicates, or the documentation states, the value will be converted to text, or like we call it: a string. Gets the specified parameter as a **text** string by its ...
  • 6,431
7 votes
Accepted

Getting multiple value pairs as Python Script tool parameter?

Python Toolbox: If your script is in a Python Toolbox, you can use a Value Table (GPValueTable). def getParameterInfo(self): param0 = arcpy.Parameter( displayName='Elevation and ...
  • 58.7k
7 votes

Using Boolean parameters in Python Script Tool of ArcPy?

Try adding a print useDefault immediately after you set it to see what is returned. I have a suspicion (without testing) that it may be returning 'True'(or 'False') rather than 'true' (or 'false'). ...
  • 64.5k
7 votes
Accepted

How to set .gdb as Python script tool parameter?

The parameter you need is: workspace
7 votes
Accepted

Extract values from a field to a list in Python (arcpy)

Your code looks a bit complicated. Perhaps your problem is the paths. Use the r (raw) syntax for the paths and list comprehension. Also you cant set arcpy.env.workspace to a shapefile. You can set it ...
  • 61.3k
7 votes
Accepted

Creating Checkbox list in Python script tool dialog ArcGIS Pro

Make a parameter with a Data Type = String and Multiple values enabled Set Filter to Value List and add your map names: When you run the tool, you can select individual maps from the dropdown, or ...
  • 58.7k
6 votes

Using Boolean parameters in Python Script Tool of ArcPy?

Extending @PolyGeo's answer, running this snippet from the command line and from a toolbox with a single parameter set as "boolean, optional" will give slightly different returns. import arcpy ...
  • 27.9k
6 votes
Accepted

TypeError in Script Tool

Looks like it is converting value NULL to float variable. Add an extra if condition to evaluate the variable before performing the conversion: e.g. if myValue[1] <> None: # ignoring null, ...
  • 34.8k
6 votes

ArcGIS crashing with Tkinter?

Tkinter is not compatible with any version of Arcmap desktop. As a script you are running pure python, and not using the ArcMap desktop application at all, which is why you are seeing different ...
6 votes
Accepted

Python script into model

Check 2 things: Is the script imported in the script tool? Right-click it in the Catalog > Import Script. Also, in the Model properties, make sure the 'Store relative pathnames (instead of absolute ...
  • 9,612
6 votes
Accepted

Clear the Scratch.gdb

If you want to simply overwrite existing tables then set overwrite to be true at the beginning of your script as such: arcpy.env.overwriteOutput = True Personally I don't use those system variables ...
  • 41.2k
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 ...
  • 447
6 votes
Accepted

Problems with for iteration in arcpy

In your script, calculate field will compute the values of group for ALL the row (or the selected rows if you used a layer) at each iteration. Therefore the GROUP values for all rows are overwritten ...
  • 49.1k
6 votes
Accepted

Run arcpy-script as geoprocessing tool

with regards to adding layers to the active map, the gp framework logic is like this: once a gp tool completes it's processing (aka: script execution) the gp framework iterates over all output ...
  • 3,168
5 votes
Accepted

ArcGIS python script validation to update text based on list?

Instead of if self.params[0].altered: try if self.params[0].value: I just tested and that seemed to work as you are hoping for. The .altered and .hasBeenValidated properties are super useful, but ...
  • 3,224
5 votes

Using Python new line (\n) with ArcGIS geoprocessing progress dialog?

I just created a simple Python script tool with no parameters using ArcGIS 10.3 for Desktop by adding the script below to a toolbox. import arcpy fc = r"C:\temp\abc.shp" arcpy.AddMessage(fc + "\n") ...
  • 64.5k
5 votes
Accepted

Making list of MXDs from multi-value parameter in ArcPy?

To create a multi-value input of MXD files in a tool dialog and create a Python list from them you can do the following: Write a short script like: import arcpy mxdString = arcpy....
  • 64.5k
5 votes
Accepted

MakeFeatureLayer_management where_clause input by the user

You should create a new parameter of the SQL Expression data type and then set the Obtained from option to point to the feature class parameter. This will let user see all the attributes of the ...
5 votes

Incorporating several Python script tools into one tool and have user input determine section of script run?

Something like this might work import arcpy arcpy.env.workspace = "C:\\Buffers.gdb" InPut = arcpy.GetParameterAsText(0) Situation = arcpy.GetParameterAsText(1) if Situation == 'Situation A': ...
  • 29.4k
5 votes
Accepted

ArcToolbox Date default to today

You have to modify validation script, e.g.: import arcpy, datetime class ToolValidator(object): """Class for validating a tool's parameter values and controlling the behavior of the tool's dialog....
  • 22.2k
5 votes
Accepted

Converting python script to toolbox?

You are 99% there. The issue you are having is that the arcpy.getParameterAsText is returning a semi-colon separated string.(e.g. "FCpath1;FCpath2" ) This is not a list (e.g. ['FCpath1','FCpath2'] ) ...
  • 1,594
5 votes
Accepted

What parameter's data type is Short integer in arcgis 10.3 model builder?

I would use Long (derived). This will be automatically stored in your field as a short integer if the absolute value is small enough (< 32767), but this will be an issue when its larger, so make ...
  • 49.1k
5 votes
Accepted

Creating selection record using ArcPy and Python script tool?

Unfortunately, this kind of GUI is not exposed via custom script tools. Your best choice would be to have a list of strings of MultiValue type and then let user tick the boxes besides the rows to ...
5 votes
Accepted

Add environment settings to script?

Here's my script, sets the Environment Workspace based on a folder/geodatabase, and then copies a pre-existing feature class to that workspace (based on the fact that I don't set a location for the ...
  • 29.4k

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