arcpy.nd.GetDiagramTemplateNames(in_utility_network)
|
名称
|
说明
|
数据类型
|
|
in_utility_network
|
与逻辑示意图模板名称相关的公共设施网络或追踪网络。
|
Utility Network; Trace Network
|
派生输出
|
名称
|
说明
|
数据类型
|
|
out_template_names
|
输出逻辑示意图模板名称。
|
String
|
代码示例
GetDiagramTemplateNames 示例(工作流)
导出与给定网络相关的所有逻辑示意图模板的定义。
下列脚本工具用于检索与网络相关的逻辑示意图模板列表,以及将每个模板的定义导出为给定文件夹中的 .ndbd 和 .ndld 文件。
要添加和配置此脚本工具,请完成以下步骤:
将以下脚本复制到 Python IDE 中,并以 .py 扩展名进行保存。
以新的空白工程或现有工程启动 ArcGIS Pro。
添加新工具箱,或在目录窗格中,单击工程,然后使用工具箱下的默认工程工具箱。
右键单击此工具箱,然后单击新建 > 脚本。
完成常规选项卡,如下所示:
完成参数选项卡,如下所示:
第一个参数
标注—输入输入网络。
名称—保留默认名称 Input_Network。
数据类型—选择公共设施网络和追踪网络。
类型—选择必填。
方向—选择输入。
第二个参数
单击确定。 脚本工具对话框随即关闭。
要运行脚本工具,请完成以下步骤:
展开工具箱并双击该工具将其打开。
指定输入网络参数,即浏览至数据库连接文件、文件地理数据库或移动地理数据库(引用要从中导出所有模板定义的网络)并选择。
指定输出文件夹参数,即浏览并选择要将模板定义文件导出至的输出文件夹。
单击运行。
# Name: ExportAllDiagramTemplateDefinitions.py
# Description: Export definitions of all diagram templates related to a given network.
# Import system modules
import arcpy
import os
import re
# Initialize variables
msgInputsErr = "Invalid arguments."
msgScriptErr = "Error during script operation."
ndbd_ext = ".ndbd"
ndld_ext = ".ndld"
# Set overwrite option
arcpy.env.overwriteOutput = True
# Decodes parameters
try:
input_Network = arcpy.GetParameterAsText(0)
input_Folder = arcpy.GetParameterAsText(1)
if input_Network == "" or input_Folder == "" :
raise Exception()
except Exception:
arcpy.AddError(msgInputsErr)
raise
# Main code
try:
arcpy.AddMessage("Retrieving the templates list...")
output_TemplateNames = arcpy.nd.GetDiagramTemplateNames(input_Network)
templateNamesList = re.split(';', str(output_TemplateNames))
arcpy.AddMessage("Looping on each template...")
for template in templateNamesList:
message = "Exporting template: {}".format(template)
arcpy.AddMessage(message)
arcpy.nd.ExportDiagramTemplateDefinitions(input_Network, template,
os.path.join(input_Folder, template + ndbd_ext),
os.path.join(input_Folder, template + ndld_ext))
except Exception:
arcpy.AddError(msgScriptErr)
raise