Calculate Value

366
1
11-04-2022 05:01 AM
ammsgis
New Contributor III

I want to create a tool which be capable to read the feature's name with python's expression so I add Parse Path to the feature and add the Calculate Value tool in model builder flow with this command line.

Expression: Name == '%Name%'

Code block:
import difflib
Name=='%Name%'
def funcao(Name):
n = 1
cutoff = 0.8
lista = ['hid', 'hidrography']
close_matches = difflib.get_close_matches(Name, lista, n, cutoff)
while len(close_matches)>=1:
return True
else:
return False

Although the syntax is correct, the expression doesn't work because the result value is not what I want.

My desire was after this Calculate Value results the correct value i will link to If Value is (Value test) and then it would be possible branching the process.

Any suggestions and corrections are welcome!

0 Kudos
1 Reply
RhettZufelt
MVP Frequent Contributor

Hard to decipher what you are tyring to do without proper code formatting.

One thing that is obvious righ away is that you are not running the function.  The expression line is where you call the code block function:

funcao(!FieldName!)

Maybe check out some of the examples here.

R_