Modelbuilder freezing at random points

448
1
03-20-2022 05:00 PM
Labels (2)
CharlesCurtin
New Contributor II

Hi all,

I've attached a screenshot of the model I'm trying to run. Essentially, it iterates through the polylines in a layer and for each line, generates points, and then splits each line at the points. The outputs are routed into a geodatabase as individual layers.  I have multiple polyline layers I have to use this model for, and the one I'm attempting first has 1,700 or so features, which is the least out of any of the layers. The problem is that the model keeps freezing at random points between 100-600 outputs created when routed to a geodatabase. Interestingly, when I routed the outputs to a folder on the desktop, it ran smoothly and through all the features without any problems, but lost geometry and created problems when the resulting shapefiles were used later. I'm running this and pulling all data from the local drive, but I just can't seem to increase the performance enough to put the outputs into a geodatabase. 

If scripting would make the process quicker, I've also tried using a search cursor to accomplish the same thing. The script runs once and accomplishes what I need for a single feature and then stops. I can't get the cursor to step to the next row, so here's the code if there's a simple improvement there. 

import arcpy

arcpy.env.workspace = "C:\\Users\\ccurtin\\Desktop\\Data\\ES_Routes\\UPC\\King_JR_ES.gdb"

arcpy.env.overwriteOutput = False

field = ["OBJECTID"]

cursor = arcpy.da.SearchCursor("King_JR_ES_Routes", field)

with arcpy.da.SearchCursor("King_JR_ES_Routes", field) as cursor:
    for row in cursor:
        select = "OBJECTID = {}".format(row[0])
        arcpy.management.SelectLayerByAttribute("King_JR_ES_Routes", "NEW_SELECTION", select, None)
        arcpy.management.GeneratePointsAlongLines("King_JR_ES_Routes", r"C:\Users\ccurtin\Desktop\Data\ES_Routes\UPC\King_JR_ES.gdb\King_JR_ES_points_%n%", "DISTANCE", "150 Feet", None, None) 
        arcpy.management.SplitLineAtPoint("King_JR_ES_Routes", r"C:\Users\ccurtin\Desktop\Data\ES_Routes\UPC\King_JR_ES.gdb\King_JR_ES_points_%n%", r"C:\Users\ccurtin\Desktop\Data\ES_Routes\UPC\King_JR_ES.gdb\King_JR_ES_splitroutes_%n%", "5 Feet")

 

Any help would be much appreciated, whether it be an improvement to the model, system performance tips, or script improvement. Thanks!

0 Kudos
1 Reply
RhettZufelt
MVP Frequent Contributor

Are you trying to create a separate featureclass for each line segment (so, 1700+ feature classes in the FGDB for the 'small' datset)?

for one, you don't need the first cursor = ... line.  the "with arcpy.... as cursor:" will establish the cursor for you.

also, the select and select layer by attribute select statement is telling it if this row = this row, then do stuff.

Since OBJECTID is unique, it is only going to select one row, and, that is the row that is already selected by the cursor.

I'm not where I can test, but can you Generate points along line, and split line at point outside of the cursor on the entire featureclass or does the tool behave differently when performed on only one line at a time? could even save them as memory datasets to increase performance.

Then all you would need to do is iterate through the lines in the split lines at point output, and copy/insert to new featureclass.

R_

 

 

 

0 Kudos