0

I don't use python all the time.

In a point feature class, I'm trying to populate an ID field with 1's and 0's based on whether the FID is divisible by 28.

I've started the following code but can't get it to execute:

enter image description here

def myCalc(FID,ID):
  if FID % 28 == 0:
    return 1
  else:
    return 0
3
  • 1
    Do you need "ID" as an input in your function? Or are you trying to return 1 and 0 to ID? Also the screen shot shows that VBA is selected. Have you tried it with Python selected?
    – F_Kellner
    Commented Oct 15, 2015 at 15:12
  • 1
    make sure you are setting the parser to Python. In the screenshot you have it a VB
    – mr.adam
    Commented Oct 15, 2015 at 15:12
  • I'm trying to return 0 and 1 to ID Commented Oct 15, 2015 at 15:27

1 Answer 1

1

Just for completeness, to summarise what was said in the comments:

You don't need "ID" as an input parameter of your function.

def myCalc(FID):
  if FID % 28 == 0:
    return 1
  else:
    return 0

So, when you call the function, all you need is:

myCalc(!FID!)

Also, ensure the parser is set to Python.

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.