ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • ヘルプ
  • Sign Out
ArcGIS Desktop

ArcGIS Online

組織のマッピング プラットフォーム

ArcGIS Desktop

完全なプロ仕様の GIS

ArcGIS Enterprise

エンタープライズ GIS

ArcGIS Developers

位置情報利用アプリの開発ツール

ArcGIS Solutions

各種業界向けの無料のテンプレート マップおよびテンプレート アプリケーション

ArcGIS Marketplace

組織で使えるアプリとデータを取得

  • ドキュメント
  • サポート
Esri
  • サイン イン
user
  • マイ プロフィール
  • サイン アウト

ArcMap

  • ホーム
  • はじめに
  • マップ
  • 解析
  • データ管理
  • ツール
  • エクステンション

ApplyLayoutRules

Production Mapping ライセンスで利用できます。

  • 概要
  • ディスカッション
  • 構文
  • コードのサンプル

概要

Applies layout rules to a map document to adjust page size and position of surround elements.

ディスカッション

Layout rules allow you to define the relative placement of surround elements on the page layout and dynamically adjust your page sizes. You can create placement rules that will maintain consistent placement across all map documents. You can create placement rules for any surround element.

Layout rules can be configured using the Layout window in ArcMap. You can then automate the layout position of elements on a map-making application using the ApplyLayoutRules function. The function also supports Data Driven Pages-enabled MXDs. In Data Driven Pages, it allows you to control the layout when you switch from page to page and the position of elements change, such as titles or legends.

For more information, see What are layout rules?

構文

ApplyLayoutRules (map_document, layout_rules_file)
パラメーター説明データ タイプ
map_document

A variable that references a MapDocument object.

MapDocument
layout_rules_file

A path to a file that contains the layout rule settings.

String

コードのサンプル

ApplyLayoutRules example 1

This script shows how layout rules can be applied to a single MXD.

import arcpy
import arcpyproduction

# Check out Production Mapping extension
arcpy.CheckOutExtension("foundation")

# Define variables
mxd = arcpy.mapping.MapDocument('CURRENT')
rules = r"C:\Project\LayoutRules.xml"

# Apply the Layout Rules from LayoutRules.xml
arcpyproduction.mapping.ApplyLayoutRules(mxd, rules)

# Check in Production Mapping extension
arcpy.CheckInExtension("foundation")
ApplyLayoutRules example 2

This script shows how layout rules can be applied to Data Driven Pages. You can move from page to page and layout rules are applied to ensure layout elements don’t overlap.

import arcpy
import arcpyproduction
import os

# Check out Production Mapping extension
arcpy.CheckOutExtension("foundation")

# Define variables
mxd = arcpy.mapping.MapDocument(r'C:\Project\CountiesDDP.mxd')
mxdddp = mxd.dataDrivenPages
rules = r"C:\Project\LayoutRules.xml"

# Process each page in the map document and apply layout rules
for page in range(1, mxdddp.pageCount+1):
    mxdddp.currentPageID = page
    ddp_row = mxdddp.pageRow
    ddp_field = mxdddp.pageNameField
    val = ddp_row.getValue(ddp_field.name)
    arcpyproduction.mapping.ApplyLayoutRules(mxd, rules)
    
# Apply a definition query to see only the features of interest
    lyr_list = arcpy.mapping.ListLayers(mxd)    
    for lyr in lyr_list:
        if lyr.name.find("Counties") > -1:
            lyr.definitionQuery = "NAME = '"+val+"'"
         	
	# Export to PDF
    outpdf = r"C:\Project\PDF"+os.sep+str(mxdddp.currentPageID)+"page.pdf"
    mxdddp.exportToPDF(outpdf,"CURRENT")
    print "Exported " + outpdf
	
# Reset the definition query
for lyr in lyr_list:
    if lyr.name.find("Counties") > -1:
        lyr.definitionQuery = ""
		
# Check in Production Mapping extension
arcpy.CheckInExtension("foundation")

ArcGIS Desktop

  • ホーム
  • ドキュメント
  • サポート

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

Esri について

  • 会社概要
  • 採用情報
  • Esri ブログ
  • ユーザ カンファレンス
  • デベロッパ サミット
Esri
ご意見・ご感想をお寄せください。
Copyright © 2021 Esri. | プライバシー | リーガル