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:
array.add(pt)
cur.insertRow(arcpy.Polyline(array))
which throws the error:
cur.insertRow(arcpy.Polyline(array)) TypeError: argument must be sequence of values
Can somebody help me with the code?
Hornbydd
44.9k5 gold badges42 silver badges84 bronze badges
asked Mar 15, 2016 at 4:44
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@"])
cur.insertRow([line_geometry])
answered Mar 15, 2016 at 14:48
-
Yes Its Working Now, thank you so much. but could not Understand what just happened by adding parenthesis ?Akhil Kumar– Akhil Kumar2016年03月16日 03:54:09 +00:00Commented 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.2016年03月16日 08:26:40 +00:00Commented Mar 16, 2016 at 8:26
lang-py