AnsweredAssumed Answered

Problem in a Buton addin

Question asked by ikbelkachbouri on Sep 21, 2018
Latest reply on Sep 25, 2018 by ikbelkachbouri

I have created a button and I want that when a click a field in the attribute table is filled after having made a calculation but it does not work.

This is my code :

 

class ButtonClass1(object):

"""Implementation for Bouton_addin.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
inTable = "Bati_Service"
fieldName = "tax"
expression = "getClass(float(tax))"
codeblock = def getClass(tax):
if (SUP < 100):
tax= (pourc_serv /100)* SUP * 2
elif (SUP > 100 And [SUP] < 200):
tax= (pourc_serv /100)* (SUP * 3.8 )
elif (SUP > 200 And [SUP] < 400):
tax= (pourc_serv /100)* (SUP * 5.4 )
elif (SUP > 400):
tax= (pourc_serv /100)* (SUP * 6.4 )
# Execute AddField
arcpy.AddField_management("Bati_Service","tax", "Double")
# Execute CalculateField
arcpy.CalculateField_management("Bati_Service","tax","tax", "PYTHON","")

Outcomes