How to Compare feature class in Model Builder?

974
1
10-29-2016 05:46 AM
LeandroBenicio_de_Souza1
New Contributor

HI, I'm trying  to compare the feature classe in 2 geodatabase, and make an APPEND if the name is the same. I'm trying with WHILE but not work correct. How can I do it?

0 Kudos
1 Reply
curtvprice
MVP Esteemed Contributor

If then is tricky with ModelBuilder.

I think the most straightforward way to do this is to do the compare with a Python function inside a Calculate Value tool. Have your function return 1 or 0 and make the returned value a precondition to your append operation.

expression

test_same(r"%Featureclass1%", r"%Featureclass2%")

code block

def test_same(fc1, fc2):
  nm1 = arcpy.Describe(fc1).name.lower()
  nm2 = arcpy.Describe(fc2).name.lower()
  if nm1 == nm2:
    return 1
  else:
    return 0