arcgis python 布局中所有元素平移

天涯浪子 提交于 2019-11-27 16:45:17
# Author:  ESRI
# Date:    July 5, 2010
# Version: ArcGIS 10.0
# Purpose: This script will loop through every page layout element and apply the
#          specified X and Y shifts to each element. The script is helpful for
#          repositioning the elements so they are better aligned with the printer
#          margins/page.  This script is intended to run as a script tool and
#          has four parameters:
#               1) Input map document,
#               2) X shift,
#               3) Y shift,
#               4) Output map document.

import arcpy, os
import arcpy.mapping as MAP

#Read parameters from dialog
mxdPath = arcpy.GetParameterAsText(0)
xShift = arcpy.GetParameterAsText(1)
yShift = arcpy.GetParameterAsText(2)
outPath = arcpy.GetParameterAsText(3)

#Reference the map document
MXD = MAP.MapDocument(mxdPath)

#Loop through each page layout element and shift the x and y values
for elm in MAP.ListLayoutElements(MXD):
    elm.elementPositionX = elm.elementPositionX + float(xShift)
    elm.elementPositionY = elm.elementPositionY + float(yShift)

#Save changes to new MXD and automatically open
MXD.saveACopy(outPath)
os.startfile(outPath)

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!