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 ...
Sethdd's user avatar
  • 526
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 ...
PhilippNagel's user avatar
  • 1,712
7 votes
Accepted

How to set .gdb as Python script tool parameter?

The parameter you need is: workspace
T. Wayne Whitley's 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 ...
BERA's user avatar
  • 72.8k
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 ...
user2856's user avatar
  • 65.9k
6 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....
FelixIP's user avatar
  • 23k
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, ...
artwork21's user avatar
  • 35.1k
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 ...
Richard Fairhurst's 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 ...
GISGe's user avatar
  • 9,674
6 votes
Accepted

Controlling Categories in Script Validation Tools - Expanding Groups By Default

This isn't possible in python, but you can by using a custom stylesheet. Copy "C:\Program Files (x86)\ArcGIS\Desktop10.2\ArcToolbox\Stylesheets\MdDlgContent.xsl" to the same folder as your script. ...
user2856's user avatar
  • 65.9k
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 ...
Hornbydd's user avatar
  • 43.4k
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 ...
Jonas's user avatar
  • 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 ...
radouxju's user avatar
  • 49.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 ...
gotchula's user avatar
  • 3,203
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'] ) ...
Ben S Nadler's user avatar
  • 1,604
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 ...
radouxju's user avatar
  • 49.7k
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 ...
Alex Tereshenkov's user avatar
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 ...
Midavalo's user avatar
  • 29.7k
5 votes
Accepted

Maintaining sorted unique values in value table of ArcGIS Pro Python script tool validation?

You don't have to make a value for the parameter by loading it from a string. It's enough just to do the assignment: def updateParameters(self): self.params[0].value = sorted(list(set(self.params[0]...
Alex Tereshenkov's user avatar
5 votes

For-Looping through Bookmarks in Python Script tool?

you need to add the export function inside the for loop, indent the line for bkmk in bkmks: mf.zoomToBookmark(bkmk) lyt.exportToPDF(r"C:\arcGIS_Shared\Exports" + "\\" + bkmk.name + ".pdf")
NULL.Dude's user avatar
  • 2,131
5 votes

Applying Definition Query for multiple features using ArcPy?

You need a colon after your line: if layer.supports(definitionQuery) should be: if layer.supports(definitionQuery): You should also consider modifying your query as was commented by @smiller. It ...
Fezter's user avatar
  • 21.9k
4 votes
Accepted

Script Tool Automation of Search and Update Cursor?

The required input for field names on a cursor is a list of fields and your function resetFieldList is returning a string, not a list. Try something like this: def resetFieldList(InitialFieldList): ...
Evan's user avatar
  • 930
4 votes
Accepted

Setting up Python script to read tool parameters from table?

You can use an arcpy.da.SearchCursor() to load your parameter values from a table into a dictionary. My table of parameters: import arcpy myParamsTable = r"D:\temp\SE\SEData.gdb\MyParameters" # ...
Midavalo's user avatar
  • 29.7k
4 votes

Saving last selected value in Python Script Tool?

Use Geoprocessing Results list - re-opening a previously run tool will include any parameters selected when that tool was run. Geoprocessing Menu > Results In Results tab open the previously run ...
Midavalo's user avatar
  • 29.7k
4 votes
Accepted

Converting Python script tools from arcgisscripting to ArcPy?

Remove your Try/Except so that you get all errors in full and just run it again. It should tell you the line that's not working and you'll know where to focus next. Double-check your capitalization - ...
Midavalo's user avatar
  • 29.7k
4 votes
Accepted

ArcGIS crashing with Tkinter?

I think the trick to using tkinter in Python is to run it from an external module, that way it isn't competing with the GUI components from the pythonaddins module. I do not take any credit for the ...
crmackey's user avatar
  • 8,484
4 votes

Returning results from script tool in Geoprocessing Results window?

You need to change the print line to arcpy.AddMessage(): import arcpy arcpy.env.workspace = r"F:\Shared\DDS\GIS\Infrastructure\DATAMIGRATE\CURRENTPROJ\HOUSTON_PLAT_TRACKER\ESRI\ImportAndCleanLines\...
Midavalo's user avatar
  • 29.7k
4 votes
Accepted

Tool script multi-value parameter, Input raster does not exist

If the name has spaces, ArcGIS will wrap it in single quotes. Use something like rasters = [f.strip("'") for f in rasters.split(";")]
user2856's user avatar
  • 65.9k
4 votes
Accepted

Selecting Multiple Layers with ArcPy?

When you go to create your script in ArcMap or Catalog, you'll want to go into the properties dialog and set your input field (of any type you need) to allow Multi Values, as circled in red here: ...
AlecZ's user avatar
  • 2,633
4 votes
Accepted

Why is "arcpy.GetParameterAsText" deleting Target Feature Class?

It seems that if a feature class data type parameter defined as output: And also the output feature class already exists then the script processor from the toolbox deletes the output feature class ...
Michael Stimson's user avatar

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