Hi,
I have a script that creates a new field and then chooses the field of diameter and runs an equation to convert it from millimeters to meters and then makes a Buffer
But there is a problem with the script that I don't know about
Note: This is my first try
My script
Import arcpy
# Script arguments
Input_Feature == arcpy.GetParameterAsText(0)
Field == arcpy.GetParameterAsText(1)
Output_Feature == arcpy.GetParameterAsText(2)
New_Field == "Buf"
Expression == "{ }".format ((!Field!/1000)/2)
# Local variables:
Feature_2 = Input_Feature
Feature_3 = Feature_2
# Process: Add Field
arcpy.AddField_management(Input_Feature, "Buf", "FLOAT", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
# Process: Calculate Field
arcpy.CalculateField_management(Feature_2, "Buf", "Expression ", "PYTHON", "")
# Process: Buffer
arcpy.Buffer_analysis(Feature_3, Output_Feature, "Buf", Side_Type, End_Type, "NONE", "", Method)
Input_Feature == arcpy.GetParameterAsText(0)
This is not an assignment statement, it is an equality check (==), I suspect you want to assign your parameters to variables so you need to use
Input_Feature = arcpy.GetParameterAsText(0)
First, thanks for your interest
Second, I have already tried this method and it did not work. The real problem is that the script is telling the program to choose a field from the input layer and enter this chosen field into the equation
Is your script attached to a tool in Arctoolbox?
If not then you have to provide the values for the parameters either in the code or via the command line.
Input_Feature = r"C:\somefolder\some_gdb\input_featureclass"
Field = "Field_to_use"
Output_Feature = r"C:\somefolder\some_gdb\output_featureclass"
and the change from equality to assignment statements is correct.
If you intend to create a toolbox with a tool, see
A quick tour of creating tools with Python—ArcGIS Pro | Documentation
focus on the "custom" tools