I try to list all layers from an mxd. Can someone explain me why it works when launched from toolbox and not from an Idle python script ?
mxd = arcpy.mapping.MapDocument(r"...\my.mxd") for df in arcpy.mapping.ListDataFrames(mxd,"*"): for lyr in arcpy.mapping.ListLayers(mxd,"*",df): print df.name + ":" + lyr.name
When launched with a tool inside Arcmap 10.0, I get all layers, but from python 2.6 script, it just displays the first layer and stops (Layers:<first layer name>).
Thanks Matthew, your answer helped me to investigate, it worked with other mxd.
So I did a reboot and finally it's ok. A bit strange but as I did many Python tests on this machine and this mxd during the previous day, perhaps something gone wrong.