I wrote the following hard coded script which asks a user to input a number of points (X,Y) to draw a Polygon feature in a feature class and the input type is float then append these inputs in a list, and to close the program (stop or finish sketch) user have to insert any STR value in the input, once the script runs the new parcel appear on the map after refresh (zoom in/out).
This script works well with Python window & Jupyter Notebook in ArcGIS Pro.
But I want to convert this script into a toolbox in ArcGIS Pro, so I created New Toolbox > Script, added parameter 0 as Feature class and parameter 1 as String (with multiple values), the tool doesn't work and give me error:
TypeError: cannot read geometry field. empty sequence.
I tried to change parameter 1 to different datatypes like Polygon/XY/Lon but all failed.
import arcpy import os ## Following Parameters disabled so script can works well on any IDLE ## but when using Arctoolbox you have to enable this parameters and disabled any other Path # 1 Input Parameters #feature_class = arcpy.GetParameterAsText(0) #one = arcpy.GetParameterAsText(1) try: list2 =  while True: one=input() x, y = map(float, one.split(',')) a = list2.append((x,y)) except: print(list2) feature_class = "C:/Users/ProjectsName/Database.gdb/polygon" # Write feature to new feature class with arcpy.da.InsertCursor(feature_class, ['SHAPE@']) as cursor: cursor.insertRow([list2])
Also I created the following Script and it works well either Script or Arc Tool, but the input points are limited by the number of getparameter that mean I have to create 10 get parameters in script and the end user will have to use only 10 points not more/or less which doesn't make sense!
import arcpy import os feature_class = arcpy.GetParameterAsText(0) x1 = arcpy.GetParameterAsText(1) y1 = arcpy.GetParameterAsText(2) x2 = arcpy.GetParameterAsText(3) y2 = arcpy.GetParameterAsText(4) x3 = arcpy.GetParameterAsText(5) y3 = arcpy.GetParameterAsText(6) coordinates = [(x1,y1), (x2,y2), (x3,y3) ] with arcpy.da.InsertCursor(feature_class, ['SHAPE@']) as cursor: cursor.insertRow([coordinates])