0

I am sitting here already awhile and can't find an answer on my own. I actually have pretty much the same Problem which was already asked (MultiValue-String to SQL Expressions). But mine is more basic because of missing knowlegde. I tried to use the codechunk out of the other Problem but when i run it the expected Pick-List is always without Values. Some Basic Questions actually include missing comprehension of the functions.

multival = arcpy.GetParameterAsText(1)  # 'Store_1;Store_2;Store_3'
vals = multival.split(";")

where_stub = """"NAME" IN ({})"""
stores = ','.join(["'{}'".format(x) for x in vals])
where = where_stub.format(stores)

I actually don't know where the multivalcomes from and which Position its claimimg in the code. Maybe for a better understanding my task is to create a Route for a Pizza delivery with about 6 Stops. As data I got a file with 25 Stores which from I should pick various stores. To avoid a SQL-Expression I would like to have a Pick-List as in the other Problem shown (MultiValue-String to SQL Expressions).

My Code looks like this

# Import arcpy module
import arcpy
from arcpy import env

#workspace =  GetParameterAsText (0) ???
arcpy.CheckOutExtension("Network")

# Local variables:
in_network_dataset = "Transportation/Streets_ND"
outNALayerName = "BestRoute"


# Process: Make Route Layer
arcpy.MakeRouteLayer_na(in_network_dataset, outNALayerName, "TravelTime", 
"FIND_BEST_ORDER", "PRESERVE_BOTH", "", "", "ALLOW_UTURNS", 
"Oneway;RestrictedTurns", "", "", "", "")

# Process: Select
Stores = "Stores.shp"
Stores_Select = "Stores_Select_Output"
Expression = arcpy.GetParameterAsText(0)
vals = Expression.split(";")

where_stub = """"NAME" IN ({})"""
stores = ','.join(["'{}'".format(x) for x in vals])
Expression = where_stub.format(stores)


arcpy.Select_analysis(Stores, Stores_Select, Expression)

It will execute until the select-process but then it does not make a difference between my script and a totaly empty one... Can Someone explain me how to get the Parameters into my Pick-List and maybe some Ground explanation so i understand what the Codechunk from (MultiValue-String to SQL Expressions) includes?

This is how my Parameter Panel looks:

Pic1

3
  • 1
    Have you configured a tool dialog for your Python script tool?
    – PolyGeo
    Commented Mar 23, 2017 at 10:35
  • If i understand that right you mean with tool dialog the actual outcoming tool? This one would be empty an the Error000735 occures
    – GISlena
    Commented Mar 23, 2017 at 10:45
  • I don't know what you mean by an "actual outcoming tool". Please edit your question to describe how you right-clicked on a toolbox in the Catalog window and used Add Script to configure the Python script tool. We'll need to see exactly what you did on the Parameters panel.
    – PolyGeo
    Commented Mar 23, 2017 at 10:48

1 Answer 1

2

You currently have your multivalue as the third parameter on your tool dialog but you are trying to reference it using an index value of 1:

multival = arcpy.GetParameterAsText(1)

when it should be referenced using an index value of 2:

multival = arcpy.GetParameterAsText(2)

Alternatively, you could leave the parameter index numbers as they are and use the up/down arrows on the Parameters tab of the tools Properties to move the parameter order on the tool dialog to match that of your code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.