This question has been asked multiple times with proper answers(here,and here, and here as well )but I still cannot get it right.
ArcGIS 10.2.2.
I want to add via a Python standalone script a Featureclass from a file-gdb to the TOC. If I try it in the ArcGIS Python window it works fine. However in a standalone script nothing happens. There is no error message or anything. I already thought it might be a bug, but it seems to work for everyone else. I also tried it with a .lyr and it didn´t work either. Someone got a hint for me?
Here is the code (I also tried the one from the ArcGIS help site, and from all the links above).
import arcpy mxd = arcpy.mapping.MapDocument(r"C:\GIS\KUP\Check.mxd") df = arcpy.mapping.ListDataFrames(mxd, "*")[0] addLayer = arcpy.mapping.Layer(r"C:\GIS\KUP\Ergebnisse.gdb\Potenziale_singlepart_final") arcpy.mapping.AddLayer(df, addLayer, "BOTTOM") I also tried :
addLayer = arcpy.mapping.Layer(r"C:\GIS\KUP\Potenziale_singlepart_final.lyr") What am I doing wrong? I am trying for a week now. I`m getting crazy with this one. Seems so easy.
أكثر...
ArcGIS 10.2.2.
I want to add via a Python standalone script a Featureclass from a file-gdb to the TOC. If I try it in the ArcGIS Python window it works fine. However in a standalone script nothing happens. There is no error message or anything. I already thought it might be a bug, but it seems to work for everyone else. I also tried it with a .lyr and it didn´t work either. Someone got a hint for me?
Here is the code (I also tried the one from the ArcGIS help site, and from all the links above).
import arcpy mxd = arcpy.mapping.MapDocument(r"C:\GIS\KUP\Check.mxd") df = arcpy.mapping.ListDataFrames(mxd, "*")[0] addLayer = arcpy.mapping.Layer(r"C:\GIS\KUP\Ergebnisse.gdb\Potenziale_singlepart_final") arcpy.mapping.AddLayer(df, addLayer, "BOTTOM") I also tried :
addLayer = arcpy.mapping.Layer(r"C:\GIS\KUP\Potenziale_singlepart_final.lyr") What am I doing wrong? I am trying for a week now. I`m getting crazy with this one. Seems so easy.
أكثر...