I am currently receiving an error code of: Traceback (most recent call last):įile "C:\Users\Richard.Lauberts\Documents\LIS Data\Toolbox and Scripts\Python Script for Splitting MasterMap by Site.py", line 26, in Īrcpy.SelectLayerByLocation_management('OSMM_Line_Detail',"WITHIN_A_DISTANCE",layerName,'110 Meters',"NEW_SELECTION")įile "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 6618, in SelectLayerByLocationĮxecuteError: Failed to execute. #Exports the selection of layer to new directoryĪrcpy.FeatureClassToShapefile_conversion(arcpy.GetParameterAsText(2), ""C:\Users\USERNAME\Documents\Test Data\Basemapping and Boundary Data\Split line by area\Line " layerName)Īrcpy.AddMessage("\n Completed split for " layerName) #Select the wanted layer that is within a distance of the current layerĪrcpy.AddMessage("\n Select by location")Īrcpy.SelectLayerByLocation_management('OSMM_Line_Detail',"WITHIN_A_DISTANCE",layerName,arcpy.GetParameterAsText(3),"NEW_SELECTION")ĭirname = ("C:\Users\USERNAME\Documents\Test Data\Basemapping and Boundary Data\Split line by area\Line " layerName)Īrcpy.AddMessage("\n Directory not found, creating directoy for: " layerName)
#For loop to iterate through all layers in dataframeįor lyr in (mxd,"",df):Īrcpy.AddMessage("\n Skipping " layerName)Īrcpy.AddMessage("\n Processing: " layerName) Mxd = (arcpy.GetParameterAsText(0))ĭf = (mxd, "Frame")Ī = arcpy.GetParameterAsText(1) #References users Map document - get parameter input from prompt #Script to split one layer (OSMM/OSVML) into parts, parts defined by another layer. Here is my code: arcpy.AddMessage("\n Checking Script for Errors.") The idea is that the script will cycle through the layer files, select the polyline parts that sit within X meters and export them to a separate folder.
I have a large polyline dataset that I am trying to split up by several separate polygon layer files. I've been banging my head against a wall trying to get arcpy.SelectLayerByLocation_managerment to work and cannot find a solution - I am using ArcMap/Catalog 10.2.