AnsweredAssumed Answered

How to add Route Layer to Map using Arcpy.nax, Pro 2.5?

Question asked by jacquelinewillan on Aug 10, 2020
Latest reply on Aug 11, 2020 by jacquelinewillan

What is the best way to generate a route, that can be saved as a route, and displayed on the map, using Pro 2.5? I created a route using the arcpy.nax module (which I found is faster than using the arcpy.na to Make a Route Analysis Layer), and was able to save as a layer file:

routeLyr = result.saveAsLayerFile(WorkSpace + os.path.sep +  RouteName + ".lyr"), but then I want to add it to the map and choose the colors. When I tried the code below, I got an error: on the line for the mp.LayerFile:

 

curPrj = arcpy.mp.ArcGISProject("CURRENT")
curMap = curPrj.listMaps("*")[0]

layerPath = WS + os.path.sep + RouteName + ".lyr"
lf = arcpy.mp.LayerFile(layerPath)

 

I also tried: 

 

lf = arcpy.mp.LayerFile(routeLyr ), but got an error for that too.  In 10.6 my users liked the fact that they could generate some routes and then go back later and add barriers, and to do that I can't just export the route to a feature class. Is there an alternate method to save/export the route? 

 

Any help on how to use python to display the layer or an alternate way to save/export a route would be greatly appreciated!

Outcomes