I have a Network Analysis Layer and I would like to export one of its classes as a .lyr file. Doing this in the GUI is easy enough, just right click and export as a layer.
However, in arcpy and ModelBuilder, I have been trying to use CopyFeature replicate this process. It works for the most part, but the exported layer loses the ObjectID attribute (the temporary file before FeaturetoPoint also is missing ObjectID), which is retained when I do this through the GUI.
Here is the code exported from ModelBuilder:
dir = "C:\\Users\\Ariel\\Dropbox\\Maps\\Geo_Data\\" Origins = "OD Cost Matrix\\Origins" v170614_OD_Cost_Matrix_Final_lyr__2_ = dir + "170614_OD_Cost_Matrix_Final.lyr" temp_origin_shp = dir + "temp_origin.shp" v170623_Origins_shp = dir + "170623_Origins.shp" # Process: Copy Features tempEnvironment0 = arcpy.env.extent arcpy.env.extent = 170614_OD_Cost_Matrix_Final.lyr (2) arcpy.CopyFeatures_management(Origins, temp_origin_shp, "", "0", "0", "0") arcpy.env.extent = tempEnvironment0 # Process: Feature To Point arcpy.FeatureToPoint_management(temp_origin_shp, v170623_Origins_shp, "CENTROID")
I could probably try to export the attribute table and then join it back in in python, but might anyone know why CopyFeatures fails in this manner?