Select to view content in your preferred language

Difference between python toolbox and python external ?

942
2
Jump to solution
02-27-2012 10:57 AM
OlivierOlivier
Regular Contributor
Hi,

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 for any help

Olivier
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MathewCoyle
Honored Contributor
It worked fine for me from IDLE. Have you tried it using different mxds?

View solution in original post

0 Kudos
2 Replies
MathewCoyle
Honored Contributor
It worked fine for me from IDLE. Have you tried it using different mxds?
0 Kudos
OlivierOlivier
Regular Contributor
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.

Olivier
0 Kudos