1

I am using ArcGIS Pro 3.0.3.

I have a model that is using inline variable substitution to pass a list of streets to my calculate value tool. This is an optional variable that is set as type Multiple Values [String], so the user may pass in nothing if they choose.

model

variable property

model property

I thought it would enter my function as None or empty string '', but if the parameter is blank then I see the variable name just gets entered as the string itself. For testing purposes, the code block below just returns the input parameter so I could see what value I got. In the real model, there are if / else statements to run different logic based on the input streets.

model message

If I add a test for st_to_exclude == "%Streets to Exclude%" inside the code block, then the inline variable substitution takes effect and whatever they entered will replace the "%Streets to Exclude%" in the code block, resulting in always true.

How do I test if the user passed in a value or left the variable empty? Or is there another workflow / function I should be using for this?

2
  • Are you opposed to adding a Calculate function? You look like you already have experience using it. You would test if your optional parameter is blank. If it is, return None, else return the value.
    – KHibma
    Dec 9, 2022 at 13:43
  • Yes that gets to the heart of the question, of "how" to test if blank. This is using the CalculateValue tool in Model Builder. I've accepted Hornbydd's answer for the time being, unless you know of another way to test for blank inputs other than looking for the name of the variable in the input as a substring.
    – sushi
    Dec 15, 2022 at 16:35

1 Answer 1

1

I think this may be a bug in ArcPro modelbuilder? I created a model just like yours and tested the various scenarios of no value, 1 value, several. When I provided a value it all worked as expected. I then created a set of if/else statements in the calculate value tool and to my surprise only 1 test for "no value" actually works, this is what I had done:

def createwhereclause(s):
    if s is None:
        # Ignored!
        return "None!"
    elif s == "":
        # Ignored!
        return "Empty!"
    elif len(s) == 0:
        # Ignored!
        return "Zero!"
    elif "Streets" in  s:
        # This works!
        return ""
    else:
        # works when values are provided
        return "whereclause =" + s

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.