I'm missing something very basic here. I'm using Modelbuilder in ArcGIS Pro 2.9.5 and I'm using the Calculate Value tool to do a simple task of removing spaces from a name string, which I then want to pass on to a Make Table View tool as the name of the output file.
I'm entering an Expression in the Calculate Value tool and I'm leaving the Code Block blank. Name is a precondition. Output data type is String. I have made Value a Parameter. The output "Value" reads as expected in the code comments after the tool has run but when I try to use %Value% in the Make Table View Tool it always reads the output as a "1" so my output table is always named "1."
What am I missing? Why is Value "1" and not the string I am building in the expression?
Thanks!
Solved! Go to Solution.
Have you tried to run the tool yet? My first guess is it's just defaulting to 1 as it doesn't know the input or output.
Hi @EMiller_2,
Without knowing what the string looks like, it could be that the code is not set properly or there are other characters in the string that is preventing the character replacements. An option to fix this is:
"""Expression"""
Expression = NewString( Field or Value )
"""Code Block"""
def NewString( InsertString ):
New = None
if type( InsertString ) != str: pass
else:
if ',' in InsertString:
New = InsertString.split( ',' )
New = '_'.join( New )
else: pass
if New: return New
else: return
Thank you RPGIS,
The problem is not the code doing the conversion -- it appears to be how to pass on the result as a Value.
In the case of my code example shown above, I achieve the proper result, as you see here (below -- "John Smith" becomes "John_Smith"). But the Value in the green oval still reads as a 1.
Unfortunately my attempt to use your code example did run for me but resulted in no Value and also a 1 in the green result oval! (see last image).
I do appreciate your help.
Have you tried to run the tool yet? My first guess is it's just defaulting to 1 as it doesn't know the input or output.
I've run it every way I can think of, and the output is always "1" and not the string I am hoping to use in the next tool (Make Table View).
What I would like to do is use the variable "%Value%" in the next tool as part of the name of the output file, but what I get is an output file named "1"!
@DavidPike Your analysis is correct in that the tool is not receiving/recognizing the input I am trying to give it, so it appears that it always returns a "1." That is the short answer! I will leave it there for now. Thank you to all for the help.