14 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 ...
user avatar
  • 516
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 ...
user avatar
  • 53.4k
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 ...
user avatar
  • 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 ...
user avatar
  • 1,692
9 votes
Accepted

ArcGIS Python Script Tool Field Name Drop Down?

Change the "Obtained from" property for the input to the shapefile parameter.
user avatar
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 ...
user avatar
  • 3,895
7 votes
Accepted

Getting shapefile name with ArcPy code?

You can do this using 2 os.path functions (splitext and basename): import os os.path.splitext(os.path.basename(r'C:\user\shapefiles\polygon.shp'))[0] # returns 'polygon'
user avatar
  • 4,613
7 votes
Accepted

Setting up Drop-Down list in Parameters of Python script tool?

Try setting the tool validator class code to this: import arcpy class ToolValidator(object): """Class for validating a tool's parameter values and controlling the behavior of the tool's dialog."""...
user avatar
  • 8,384
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 ...
user avatar
  • 6,269
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 ...
user avatar
  • 53.4k
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'). ...
user avatar
  • 63.9k
7 votes
Accepted

How to set .gdb as Python script tool parameter?

The parameter you need is: workspace
user avatar
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 ...
user avatar
  • 53.9k
6 votes
Accepted

Convert a Toolbox (.TBX) to a Python script (.PY)?

For third party toolboxes, there will either be an associated python script or the script will be embedded. Check the properties of the tool to see if there is a source script file. If embedded, ...
user avatar
  • 5,727
6 votes

Convert a Toolbox (.TBX) to a Python script (.PY)?

I'm not entirely sure if I understand your question, it leaves itself open to a few interpretations. The Python itself is slow: You don't need to do any conversion. Just use the standard profiling ...
user avatar
6 votes
Accepted

Writing ArcGIS Python Script Tool?

I can see a couple of things you're missing in your script tool. You need to change the mxd parameter string (the unicode object mentioned in your traceback) to a map document object. mxd = arcpy....
user avatar
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 ...
user avatar
  • 27.6k
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, ...
user avatar
  • 34.7k
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 ...
user avatar
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 ...
user avatar
  • 9,567
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 ...
user avatar
  • 39.7k
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 ...
user avatar
  • 48.7k
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 ...
user avatar
  • 3,148
5 votes

Syntax error using ArcPy Spatial Analyst module in Python

Your Try: statement is capitalised, it should be lower case - try:
user avatar
  • 53.4k
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....
user avatar
  • 63.9k
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 ...
user avatar
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") ...
user avatar
  • 63.9k
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 ...
user avatar
  • 3,184
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': ...
user avatar
  • 29.2k
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....
user avatar
  • 21.7k

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