Update: Problem Solved
I fixed it. In the Calculate Field Tool within Model Builder, I entered "!shape.area@acres!" . That resolved the issue and the model now produces the same results as the python script#
I would like to use the Calculate Field tool in ModelBuilder of ArcMap 10.5 to calculate the acres of a polygon. I understand that in python I can write !shape.area@acres!, but I'm unsure how to set up the script for the Calculate Field tool.
I can successfully run my python script within the python window, however I cannot run a model builder tool that should perform the same function. the error is as follows: ERROR 000539: SyntaxError: invalid syntax (, line 1) Failed to execute (Calculate Field).
My python script is here:
# Import arcpy module import arcpy #set path arcpy.env.workspace = "C:/desktop/TestScripting.gdb" # Script arguments Add_Parameter = arcpy.GetParameterAsText(0) if Add_Parameter == '#' or not Add_Parameter: Add_Parameter = "LonokeCounty2" # provide a default value if unspecified LonokeCounty2__2_ = arcpy.GetParameterAsText(1) if LonokeCounty2__2_ == '#' or not LonokeCounty2__2_: LonokeCounty2__2_ = "LonokeCounty2" # provide a default value if unspecified # Local variables: LonokeCounty2 = LonokeCounty2__2_ LonokeCounty2_Statistics = "C:\\Users\\chris\\Documents\\ArcGIS\\Default.gdb\\LonokeCounty2_Statistics" # Process: Add Field arcpy.AddField_management(Add_Parameter, "Acres2", "FLOAT", "", "", "", "", "NULLABLE", "NON_REQUIRED", "") # Process: Calculate Field arcpy.CalculateField_management(LonokeCounty2__2_, "Acres2", "!shape.area@acres!", "PYTHON", "")