Select to view content in your preferred language

Error 000539: Invalid Field . Failed execution of (CalculateField)

2713
10
Jump to solution
12-09-2021 06:05 AM
echlouchi
Emerging Contributor
Hello! 
I'm sure this is a simple issue, but it's stumped me.
I'm new to python, please help me.
I have calculated two equations from two fields without any problem.
When I calculate the third equation using the results of the first,
an error occurs: Error 000539: Invalid Field . Failed to execute (CalculateField).
I don't know what to do in this case.
here's my code.
--------------------------------------------------------------------------
import
arcpy
# Set environment settings
arcpy.env.workspace = arcpy.GetParameterAsText(0)
# arcpy.env.workspace = "D:\DocEnergy\DATA\BATIMENTS.gdb"
# ----------------------------------------
DDD = arcpy.GetParameterAsText(1).replace(',', '.')
DDDF = float(DDD)

fc = arcpy.GetParameterAsText(2)

# fields
CHAMP1 = arcpy.GetParameterAsText(3)
CHAMP2 = arcpy.GetParameterAsText(4)

# --------------------------------------------------
# EAUATION ET FORMULES
RESULTA1 = "!{0}!*!{1}!+{2}".format(CHAMP1, CHAMP2, DDDF)
RESULTA2 = "!{0}!*!{1}!-{2}".format(CHAMP1, CHAMP2, DDDF)

# how can I calculate this equation from the two equations RASULTA1 AND RESULTA2 ?
RESULTA = "!{0}!*!{1}!".format(RESULTA1, RESULTA2)

# Input the name of the field to be created
CHAMPS = arcpy.GetParameterAsText(5)

# Add field
arcpy.AddField_management("BATI", CHAMPS, "float", 20, 10)

# CalculateField
arcpy.CalculateField_management("BATI", CHAMPS, RESULTA, "PYTHON")
-------------------------------------------------------------------
thank you !!
0 Kudos
10 Replies
DanPatterson
MVP Esteemed Contributor

glad it worked out


... sort of retired...
0 Kudos