See if you can tweak this a wee bit to suit your purpose
import arcpy, os, traceback, sys
from arcpy import env
env.overwriteOutput = True
infc = arcpy.GetParameterAsText(0)
routeid = arcpy.GetParameterAsText(1)
outOption=arcpy.GetParameterAsText(2)
step = float(arcpy.GetParameterAsText(3))
outp=arcpy.GetParameterAsText(4)
# DERIVE OUTPUT FOLDER FROM OUTPUT FC
# Set workspace
arcpy.env.outputMFlag = "Disabled"
outFolder,theFile=os.path.split(outp)
env.workspace = outFolder
d=arcpy.Describe(infc)
SR=d.spatialReference
try:
def showPyMessage():
arcpy.AddMessage(str(time.ctime()) + " - " + message)
point = arcpy.Point()
arcpy.CreateFeatureclass_management(outFolder, theFile, "POINT", "", "DISABLED", "DISABLED", SR, "", "0", "0", "0")
arcpy.AddField_management(theFile, routeid, "TEXT", "", "", 25)
arcpy.AddField_management(theFile, "CHAINAGE", "DOUBLE")
# define number of shapes
result=arcpy.GetCount_management(infc)
nF=int(result.getOutput(0))
arcpy.SetProgressor("step", "", 0, nF,1)
# Create search cursor on input polyline
curT = arcpy.da.InsertCursor(theFile,["SHAPE@",routeid,"CHAINAGE"])
with arcpy.da.SearchCursor(infc, ("SHAPE@",routeid)) as rows:
for feat,theID in rows:
theLength=feat.length
m=int(theLength/step)
if outOption=="Chainage":
Chainages=[]
for i in xrange(m+1):
dL=step*i
Chainages.append(dL)
Chainages.append(theLength)
elif outOption=="Ends":
Chainages=[0, theLength]
elif outOption=="Middle":
Chainages=[theLength/2]
for aL in Chainages:
theP=feat.positionAlongLine (aL)
point.X=theP.firstPoint.X
point.Y=theP.firstPoint.Y
pnt=arcpy.PointGeometry(point,SR)
## theRow=(theP,theID,aL)
theRow=(pnt,theID,aL)
curT.insertRow(theRow)
arcpy.SetProgressorPosition()
del rows, curT
except NameError, theMessage:
arcpy.AddMessage (theMessage)
except:
message = "\n*** PYTHON ERRORS *** "; showPyMessage()
message = "Python Traceback Info: " + traceback.format_tb(sys.exc_info()[2])[0]; showPyMessage()
message = "Python Error Info: " + str(sys.exc_type)+ ": " + str(sys.exc_value) + "\n"; showPyMessage()
Parameters: