Can somebody tell me how to create a line geometry by mouse click with python addin?

I am using below code in python addin tool.

class ToolClass8(object):
"""Implementation for Testmsg_addin.tool (Tool)"""
def __init__(self):
    self.enabled = True
    self.cursor = 3 
    self.shape = "Line" 

def onLine(self, line_geometry):
    NewL = "NewL"
    cur = arcpy.da.InsertCursor(NewL, ["SHAPE@"])
    array = arcpy.Array()
    part = line_geometry.getPart(0)
    for pt in part:


which throws the error:

cur.insertRow(arcpy.Polyline(array)) TypeError: argument must be sequence of values

Can somebody help me with the code?

1 Answer 1


If you read the help file for a Tool Class the onLine() method returns a polyline object:

def onLine(self, line_geometry):
    cur = arcpy.da.InsertCursor("NewL", ["SHAPE@"])
  • Yes Its Working Now, thank you so much. but could not Understand what just happened by adding parenthesis ? Mar 16, 2016 at 3:54
  • 1
    @AkhilKumar It's expecting a list of strings (field names or tokens), and my answer provided only a string with a token, whereas this provides a list of one string.
    – PolyGeo
    Mar 16, 2016 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.