# Name: DeleteRoutes_Pro_Ex3.py
# Description: Delete routes in stand-alone mode using a feature service. It is recommended to work in a version and post it into the default version.
# Requires: ArcGIS Location Referencing
# Import arcpy module
# Check out license
# Set tool variables
delete_associated_calibration_points = "DELETE_CALIBRATION_POINTS"
delete_associated_events = "DELETE_EVENTS"
delete_associated_centerlines = "DELETE_CENTERLINES"
# Input LRS route network is in a feature service. Sign into portal is required to access the feature service.
arcpy.SignInToPortal('https://yourdomain.com/portal', 'username', 'password')
## Make a layer of the LRS route network from the feature service for applying selection. Here, 1 corresponds to the LRS route network
in_route_layer = arcpy.management.MakeFeatureLayer("https://yourdomain.com/server/rest/services/FeatureServiceName/FeatureServer/1", 'route_layer')
## Process: Select Layer by attribute as required
arcpy.management.SelectLayerByAttribute(in_route_layer, "NEW_SELECTION", "RouteID = 'routeid1'")
# Process : Delete Routes
arcpy.locref.DeleteRoutes( in_route_layer, delete_associated_calibration_points, delete_associated_events, delete_associated_centerlines)
# Check in license