# 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 toolmxdpath = 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,outputexcept Exception,e: import traceback map(arcpy.AddError,traceback.format_exc().split("\n")) arcpy.AddError(str(e))总结
以上是内存溢出为你收集整理的arcgis python 布局中所有元素信息报告全部内容,希望文章能够帮你解决arcgis python 布局中所有元素信息报告所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)