# Author:  ESRI
# Date: July 5, 2010
# Version: ArcGIS 10.0
# Purpose: This script generates a report of each page layout element and its
# associated properties. This script is intended to run as a scrip tool
# and requires two parameters:
# 1) Input map document,
# 2) Output text file. import arcpy, os, datetime #Read parameters from tool
mxdPath = arcpy.GetParameterAsText(0)
output = arcpy.GetParameterAsText(1) try: #Create r/w output file
outFile = open(output, "w") #Generate Report header
outFile.write("PageLayout Element Report: \n")
outFile.write("\n")
outFile.write("This report lists the properties of invidual page layout elements within a single MXD. \n")
outFile.write("\n")
outFile.write("MXD location: " + mxdPath + "\n")
outFile.write("\n")
outFile.write("Date: " + str(datetime.datetime.today().strftime("%B %d, %Y")) + "\n")
outFile.write("\n") #Reference MXD file
mxd = arcpy.mapping.MapDocument(mxdPath) #Report data frame elements
if len(arcpy.mapping.ListLayoutElements(mxd, "DATAFRAME_ELEMENT")) > 0:
outFile.write("\n")
outFile.write(" DATA FRAME ELEMENTS: \n") for elm in arcpy.mapping.ListLayoutElements(mxd, "DATAFRAME_ELEMENT"):
outFile.write("\n")
outFile.write("\t Name: " + elm.name + "\n")
outFile.write("\t X Position: " + str(elm.elementPositionX) + "\n")
outFile.write("\t Y Position: " + str(elm.elementPositionY) + "\n")
outFile.write("\t Height: " + str(elm.elementHeight) + "\n")
outFile.write("\t Width: " + str(elm.elementWidth) + "\n") #Report graphic elements
if len(arcpy.mapping.ListLayoutElements(mxd, "GRAPHIC_ELEMENT")) > 0:
outFile.write("\n")
outFile.write(" GRAPHIC ELEMENTS: \n") for elm in arcpy.mapping.ListLayoutElements(mxd, "GRAPHIC_ELEMENT"):
outFile.write("\n")
outFile.write("\t Name: " + elm.name + "\n")
outFile.write("\t X Position: " + str(elm.elementPositionX) + "\n")
outFile.write("\t Y Position: " + str(elm.elementPositionY) + "\n")
outFile.write("\t Height: " + str(elm.elementHeight) + "\n")
outFile.write("\t Width: " + str(elm.elementWidth) + "\n") #Report legend elements
if len(arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT")) > 0:
outFile.write("\n")
outFile.write(" LEGEND ELEMENTS: \n") for elm in arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT"):
outFile.write("\n")
outFile.write("\t Name: " + elm.name + "\n")
outFile.write("\t Parent data frame: " + elm.parentDataFrameName + "\n")
outFile.write("\t Title: " + elm.title + "\n")
outFile.write("\t X Position: " + str(elm.elementPositionX) + "\n")
outFile.write("\t Y Position: " + str(elm.elementPositionY) + "\n")
outFile.write("\t Height: " + str(elm.elementHeight) + "\n")
outFile.write("\t Width: " + str(elm.elementWidth) + "\n") #Report map surround elements
if len(arcpy.mapping.ListLayoutElements(mxd, "MAPSURROUND_ELEMENT")) > 0:
outFile.write("\n")
outFile.write(" MAP SURROUND ELEMENTS: \n") for elm in arcpy.mapping.ListLayoutElements(mxd, "MAPSURROUND_ELEMENT"):
outFile.write("\n")
outFile.write("\t Name: " + elm.name + "\n")
outFile.write("\t Parent data frame: " + elm.parentDataFrameName + "\n")
outFile.write("\t X Position: " + str(elm.elementPositionX) + "\n")
outFile.write("\t Y Position: " + str(elm.elementPositionY) + "\n")
outFile.write("\t Height: " + str(elm.elementHeight) + "\n")
outFile.write("\t Width: " + str(elm.elementWidth) + "\n") #Report picture elements
if len(arcpy.mapping.ListLayoutElements(mxd, "PICTURE_ELEMENT")) > 0:
outFile.write("\n")
outFile.write(" PICTURE ELEMENTS: \n") for elm in arcpy.mapping.ListLayoutElements(mxd, "PICTURE_ELEMENT"):
outFile.write("\n")
outFile.write("\t Name: " + elm.name + "\n")
outFile.write("\t X Position: " + str(elm.elementPositionX) + "\n")
outFile.write("\t Y Position: " + str(elm.elementPositionY) + "\n")
outFile.write("\t Height: " + str(elm.elementHeight) + "\n")
outFile.write("\t Width: " + str(elm.elementWidth) + "\n") #Report text elements
if len(arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT")) > 0:
outFile.write("\n")
outFile.write(" TEXT ELEMENTS: \n") for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
outFile.write("\n")
outFile.write("\t Name: " + elm.name + "\n")
outFile.write("\t Text string: " + elm.text + "\n")
outFile.write("\t X Position: " + str(elm.elementPositionX) + "\n")
outFile.write("\t Y Position: " + str(elm.elementPositionY) + "\n")
outFile.write("\t Height: " + str(elm.elementHeight) + "\n")
outFile.write("\t Width: " + str(elm.elementWidth) + "\n") #Close the file
outFile.close() #Automatically open the file in associated TXT application
os.startfile(output) #Delete all variables
del mxdPath, outFile, mxd, output except Exception, e:
import traceback
map(arcpy.AddError, traceback.format_exc().split("\n"))
arcpy.AddError(str(e))

arcgis python 布局中所有元素信息报告的更多相关文章

  1. arcgis python 布局中所有元素平移

    # Author: ESRI # Date: July 5, 2010 # Version: ArcGIS 10.0 # Purpose: This script will loop through ...

  2. arcgis python 布局视图中文本查找替换

    # Author: ESRI # Date: July 5, 2010 # Version: ArcGIS 10.0 # Purpose: This script will perform a sea ...

  3. Python自动化中的元素定位(一)

    1.使用selenium中的webdriver模块对浏览器进行操作 1)from selenium import webdriver 加载模块 2)b = webdriver.Friefox() 打开 ...

  4. python selenium中等待元素出现及等待元素消失操作

    在自动化测试中,很多时候都会有等待页面某个元素出现后能进行下一步操作,或者列表中显示加载,直到加载完成后才进行下一步操作,但时间都不确定,如下图所示 幸运的是,在selenium 2后有一个模块exp ...

  5. python字典中的元素类型

    python字典默认的是string item={"browser " : 'webdriver.irefox()', 'url' : 'http://xxx.com'} 如果这样 ...

  6. Python自动化中的元素定位xpath(二)

    1.Xpath元素定位 1)ele = b.find_element_by_xpath(‘/html/body/from/input[1]’) 2)Ele = b.find_element_by_xp ...

  7. arcgis通过 Python 使用工具 获得结果信息

    通过 Python 使用工具 ArcGIS 10 每个地理处理工具都具有一组固定的参数,这些参数为工具提供执行所需的信息.工具通常具有定义一个或多个数据集的输入参数,这些数据集一般用于生成新的输出数据 ...

  8. 一文教你读懂Python中的异常信息

    正文共:11813 字 2 图 预计阅读时间: 30 分钟 原文:https://realpython.com/python-traceback/ 译者:陈祥安 原文有所改动. 在写 Python 代 ...

  9. 14.python案例:爬取电影天堂中所有电视剧信息

    1.python案例:爬取电影天堂中所有电视剧信息 #!/usr/bin/env python3 # -*- coding: UTF-8 -*- '''======================== ...

随机推荐

  1. 制作win10系统及安装win10系统

    制作win10系统 1.登陆msdn,下载win10系统,打开迅雷下载器,复制完该段代码,直接开始下载,网址:https://msdn.itellyou.cn/ 2.下载软碟通,下载网址:https: ...

  2. angular2-cli 环境搭建

    开发工具:windows ,Vscode, npm, 前提:安装nodejs nodejs 模块全局安装路径配置:http://www.cnblogs.com/rancho-blog/p/656792 ...

  3. shell脚本编写mind

    首先我们要缩小这个问题的范围 如果在面试中被问到这样的问题,说说shell脚本编写思路 如:你是在公司主要负责zabbix监控的 对答如下:shell脚本这个说法挺广的,您看我这么跟您说吧,我在平时工 ...

  4. Computer Vision_33_SIFT:ORB_An efficient alternative to SIFT or SURF——2012

    此部分是计算机视觉部分,主要侧重在底层特征提取,视频分析,跟踪,目标检测和识别方面等方面.对于自己不太熟悉的领域比如摄像机标定和立体视觉,仅仅列出上google上引用次数比较多的文献.有一些刚刚出版的 ...

  5. 华为SDN:解决传统网络3大问题

    转:http://mp.ofweek.com/tele/a145613326756 科技潮人 2013-08-05 14:20 传统网络之困 互联网爆炸式增长,除了规模和发展速度远超之前所有曾出现的数 ...

  6. Sql Server 2017 安装问题记录

    记录了我在虚拟机中安装Sql server 2017遇到的一些问题. 安装环境: Sql server 2017 + Windows Server 2012 R2 提供两个网上的下载链接: https ...

  7. 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it (扫描线)

    2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it (扫描线) 链接:https://ac.nowcoder.com/acm/contest/163/F来源:牛客网 时间 ...

  8. G1垃圾收集器设计目标与改良手段【纯理论】

    在之前已经详细对CMS垃圾回收器进行了学习,今天准备要学习另一个全新的垃圾收集器---G1(Garbage First Collector 垃圾优先的收集器),说是一种全新的,其实G1垃圾收集器已经出 ...

  9. MySQL服务器

    ---恢复内容开始--- mysql是基于C/S端的服务器软件 mysql服务端 -server端开启 -解析指令 -对文件夹.文件.数据的增删改查 mysql客户端 -连接S段 -发送指令(sql语 ...

  10. 为RIDE创建桌面快捷方式

    问题场景:默认情况下,RIDE的图标不是自动创建的,需要手动添加.     解决方法: 在桌面上新建"快捷方式" 目标对象的位置:C:\Python27\python2.exe - ...