I am trying to create a toolbox that will execute 'Locate Features Along Routes' in multiple layers and in two active maps in ArcGIS Pro. One map contains linear features to be located, the other contains point features to be located. I believe the out_table is overwriting the previous table as the script iterates over each layer in the map. I believe I need to add lines to the script that would ensure a unique table is generated for each iteration of locate features along routes.
Code example below
Code here:
aprx = arcpy.mp.ArcGISProject("CURRENT") maps = aprx.listMaps() for map in maps: print("\nCurrent map: {}".format(map.name)) layers = map.listLayers() for lyr in layers: print("Layer: {} Broken?: {}".format(lyr.name,lyr.isBroken)) map1 = maps[0] map2 = maps[1] in_routes = arcpy.GetParameterAsText(0) out_table = arcpy.GetParameterAsText(1) for lyr in map1.listLayers(): print (" " + lyr.name) arcpy.lr.LocateFeaturesAlongRoutes(lyr, in_routes, "RouteId", "0 Feet", out_table + "//" + "{}_Located".format(lyr), "MapRouteId Line PointLocation", "FIRST", "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON") for lyr in map2.listLayers(): print (" " + lyr.name) arcpy.lr.LocateFeaturesAlongRoutes(lyr, in_routes, "RouteId", "10 Feet", out_table + "//" + "{}_Located".format(lyr), "RouteId Point FMEAS", "FIRST", "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON")