arcgis python 布局中所有元素平移

前端之家收集整理的这篇文章主要介绍了arcgis python 布局中所有元素平移前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
# 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)

猜你在找的Python相关文章