I have built a model and within the model I perform a merge. that creates a table. I have a script that creates one record from that table. I want to make a route event layer from this table. The problem I have is the script is the last thing to run so the make route event layer fails. I thought setting the precondition on the created table would make the script run before the table is used by the Make Route Event tool. Is there a way to force the script to run on the table before the Make Route Event Layer? Here is the code in my script.
table = r"C:\mdtapps\interactive\test.gdb\combined"
ridList = []
with arcpy.da.SearchCursor(table, ["RID"]) as cursor:
for row in cursor:
ridList.append(row[0])
del cursor
ridList = set(ridList)
for RID in ridList:
toMeasList = []
with arcpy.da.SearchCursor(table, ["RID", "END"], "RID = '" + RID + "'") as cursor:
for row in cursor:
toMeasList.append(row[1])
del cursor
toMeasList.sort()
with arcpy.da.UpdateCursor(table, ["END"], "RID = '" + RID + "'") as cursor:
for row in cursor:
row[0] = toMeasList[-1]
cursor.updateRow(row)
del cursor
toMeasList.sort()
with arcpy.da.UpdateCursor(table, ["OBJECTID"]) as cursor:
for row in cursor:
if row[0] == 2:
cursor.deleteRow()
del cursor
This is what my model looks like.