Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> doc = r"D:\test.mxd" >>> import arcpy >>> mxd = arcpy.mapping.MapDocument(doc) >>> DFList = arcpy.mapping.ListDataFrames(mxd) ### first with just empty mxd >>> del mxd >>> mxd = arcpy.mapping.MapDocument(doc) >>> DFList = arcpy.mapping.ListDataFrames(mxd) >>> arcpy.mapping.ListBrokenDataSources(mxd) ### then added windrosepoints, deleted the dataset, ensured it was broken, this is result. [<map layer u'windrosepoints'>]
This is not the first time I have encountered an issue where something fails in an external python window but works inside of arc.
mxd = arcpy.mapping.MapDocument("C:\\MappingStuff\\Untitled.mxd") try: DFList = arcpy.mapping.ListDataFrames(mxd) except: print "The MXD at "+mxd.filePath+" is empty or layers could not be listed." arcpy.AddMessage("The MXD at "+mxd.filePath+" is empty or layers could not be listed.")
arcpy.AddMessage(mxd) DFList = arcpy.mapping.ListDataFrames(mxd)
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.