How to make this script take a list of distances along a selected line and create a point featureclass with points at these distances?

import arcpy
from arcpy import env
import os

arcpy.env.overwriteOutput = True
arcpy.env.workspace = "in memory"



cursor = arcpy.da.InsertCursor("PointsOnLines",["SHAPE@XY"])
distances = [30,60,90]
for distance in distances: 
    for row in arcpy.da.SearchCursor("SelectedLine", ["SHAPE@"]):  
       point = cursor.insertRow(row[0].positionAlongLine(distance["SHAPE@XY"])   

After running this I end up with this error.

Runtime error 
Traceback (most recent call last):
File "<string>", line 20, in <module>
TypeError: 'PointGeometry' object has no attribute '__getitem__'

1 Answer 1


I think this line:

point = cursor.insertRow(row[0].positionAlongLine(distance["SHAPE@XY"]) 

should be:


As a side note if you read the help page Accessing data using cursors you will see best practise using the with statement. This guarantees the cursor being released correctly, as it stands your code is not "cleaning up" after itself and this may cause problems later on in the code.

  • 1
    Most likely cursor.insertRow((row[0].positionAlongLine(distance),))
    – FelixIP
    May 9, 2016 at 0:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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