I was able to get the first part to work (create polygon from mouse clicks). However, now I am having issues with the "copy features" and "append" tools. The end goal for the tool is for a user to be able to draw a polygon, save it, draw another polygon, and then append every polygon to that same file. Below is the code I have so far:
import arcpy
import pythonaddins
import os
class CreateNewPolygon(object):
"""Implementation for NewPolygon_addin.CPNtool (Tool)"""
def __init__(self):
self.enabled = True
self.cursor = 3
self.shape = "Line"
def onLine(self, line_geometry):
array = arcpy.Array()
part = line_geometry.getPart(0)
for pt in part:
print pt.X, pt.Y
array.add(pt)
array.add(line_geometry.firstPoint)
polygon = arcpy.Polygon(array)
# Local Variables
Input = polygon
NewPolygons = "C:\Arcfiles\test.gdb\NewPolygons"
# Process: Append Polygon to existing file or Create new file if one is not created.
if arcpy.Exists("NewPolygons"):
arcpy.Append_management(Input, NewPolygons, "Test", "", "")
else:
arcpy.CopyFeatures_management(Input,NewPolygons, "", "0","0","0")