try: # Iterates through each of the input text files for v in list(table): # Removes the file extension tableName = os.path.splitext(v)[0] # Variables tableName_line = tableName + str("_line.shp") tableName_vctor = tableName + str("_vctor.shp") tableName_e = tableName + str ("_e.shp") gate = r"C:\gis\gate.shp" tableName_sim = tableName + str("_sim.shp") # Creating vectors from xy coordinates gp.Toolbox = r"C:\Program Files\ArcGIS\ArcToolbox\Toolboxes\Military Analyst Tools.tbx" gp.TableToLine_ma(v, tableName_line, "Decimal Degrees", "sLat", "sLon", "eLat", "eLon", "False", "False") gp.Project_management(tableName_line, tableName_vctor, "PROJCS['LCC']") #Selecting vectors that intersect a line, then points that intersect the vector, then removing the initial selection gp.SelectLayerByLocation(tableName_vctor, "intersect", gate, "NEW_SELECTION") gp.SelectLayerByLocation(tableName_e, "intersect", tableName_vctor, "ADD_TO_SELECTION") gp.SelectLayerByLocation(tableName_vctor, "intersect", gate, "REMOVE_FROM_SELECTION") # Write the selected features to a new feature class in the folder gp.CopyFeatures(tableName_sim, r"C:\gis\temp") except: #If an error occurred while running the script, then print the messages print gp.GetMessages()
Solved! Go to Solution.
try: gp.SelectLayerByLocation_management(tableName_e_lyr, "intersect", tableName_vec_lyr, "", "ADD_TO_SELECTION") print gp.GetMessages() except: print gp.GetMessages(2)