I'm really sorry that nothing is working for you 😞 Which Service Pack you are using? I'm on 10 sp5. The tool is working as expected on my machine. Let me know if are on a different service pack - I'll try on that setup.
import arcpy try: mxd = arcpy.mapping.MapDocument(r"D:\Risk_Models\Multi_Species_Sampling\multi_species_overlay.mxd") df = arcpy.mapping.ListDataFrames(mxd)[0] newlayer1 = arcpy.mapping.Layer("D:\\Risk_Models\\state_MN_5000_EAB_plots.lyr") print newlayer1 arcpy.mapping.AddLayer(df, newlayer1, "TOP") arcpy.RefreshActiveView() arcpy.RefreshTOC() #save the map to persist the added layer mxd.save() del mxd, df, newlayer1 print 'Done' except Exception as ex: print ex.args[0]
except Exception as ex: print ex
import arcpy try: mxd = arcpy.mapping.MapDocument(r"C:\temp\mymap.mxd") df = arcpy.mapping.ListDataFrames(mxd)[0] newlayer1 = arcpy.mapping.Layer(r"C:\data\redlands.gdb\rdls_street") print newlayer1 arcpy.mapping.AddLayer(df, newlayer1, "TOP") arcpy.RefreshActiveView() arcpy.RefreshTOC() # save the map to persist the added layer mxd.save() del mxd, df, newlayer1 print 'Done' except Exception as ex: print ex.args[0]
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.