I have a large script that does many things, but at the end it creates a buffer whose output is an existing feature class that is overwritten. That feature class is the data source for a layer that is in a mxd that is current an object in memory. For some reason, that layer from the mxd is being removed as soon as I run the buffer. I isolated the problem with the code below by saving out two mxds. When I open the 1st mxd has the layer in the TOC, but in the 2nd mxd it is gone.
sqlWellName = "NAME = " + "'" + WELL_NAME + "'" SDE_lyr = "SDElyr" arcpy.MakeFeatureLayer_management(r"C:\GDB_Connect\Editor\MAIN@DEFAULT.sde\WATER.WELLS", SDE_lyr) arcpy.SelectLayerByAttribute_management(SDE_lyr, "NEW_SELECTION", sqlWellName) mxd.saveACopy("C:\ProjectData\Map_1.mxd") arcpy.Buffer_analysis(in_features=SDE_lyr, out_feature_class=r"C:\ProjectData\DATA\AutoMap.gdb\Buffer1Mile", buffer_distance_or_field="1 Miles", line_side="FULL", line_end_type="ROUND", dissolve_option="NONE", dissolve_field="", method="PLANAR") newmxd.saveACopy("C:\ProjectData\Map_2.mxd")
Is this a bug?