• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

gisoracle

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

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)

 

posted on 2019-08-17 22:18  gisai  阅读(701)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3