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
  • 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 Oct 15 '15 at 15:12
  • 1
    make sure you are setting the parser to Python. In the screenshot you have it a VB – mr.adam Oct 15 '15 at 15:12
  • I'm trying to return 0 and 1 to ID – thecurrentwave Oct 15 '15 at 15:27
0

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, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.