import arcpy, os
infc = sys.argv[1] # make sure this is a proper path
outfc = sys.argv[2] # make sure this is a proper path
# split the output into a folder and file name
OutPath = os.path.dirname(outfc)
OutName = os.path.basename(outfc)
NameOfFile,ext = os.path.splitext(OutName) # separate file name from extension (if any)
NameOfFile = NameOfFile + ".shp" # include shape file extension
OutFC_Clean = OutPath + "\\" + NameOfFile # clean full path to output
# Get the spatial reference from the input feature class
desc = arcpy.Describe(infc)
SR = desc.spatialReference
n = 1
arcpy.CreateFeatureclass_management(OutPath,NameOfFile,"POINT",spatial_reference = SR)
arcpy.AddField_management(OutFC_Clean,"Waypoint","LONG")
# Enter for loop for each feature
#
with arcpy.da.SearchCursor(infc, ["OID@", "SHAPE@", "alternate"]) as sCur:
with arcpy.da.InsertCursor(OutFC_Clean,["SHAPE@","Waypoint"]) as iCur:
for row in sCur:
if row[2] == "False":
#insert the feature
iCur.insertRow((row[1].firstPoint,n))
n = n + 1
iCur.insertRow((row[1].lastPoint,n))
n = n + 1
else:
iCur.insertRow((row[1].lastPoint,n))
n = n + 1
iCur.insertRow((row[1].firstPoint,n))
n = n + 1