启用附件 (数据管理)

摘要

启用地理数据库要素类或表的附件。该工具用于创建必要的附件关系类和附件表,以在内部存储附件文件。

了解有关使用“附件”地理处理工具的详细信息

使用情况

  • 如果输入数据集来自企业级地理数据库,则其必须来自作为数据所有者建立的数据库连接。

  • 在可以使用添加附件工具添加附件前,必须首先使用该工具启用附件。

  • 如果地理数据库要素类或表已启用附件,则将显示警告消息,且不进行处理。

  • 启用了复本追踪并启用了存档的非版本化的数据集将在附件表上启用存档和复本追踪。

  • 分支版本化的数据集将不会注册为分支版本,也不会在附件表上自动启用复本追踪。可以通过使用注册版本启用复本追踪工具来手动处理。

参数

标注说明数据类型
输入数据集

将启用附件的地理数据库表或要素类。输入的表或要素类必须处于 10 或更高版本的地理数据库中。

Table View

派生输出

标注说明数据类型
更新的输入数据集

已更新的输入数据集。

表视图

arcpy.management.EnableAttachments(in_dataset)
名称说明数据类型
in_dataset

将启用附件的地理数据库表或要素类。输入的表或要素类必须处于 10 或更高版本的地理数据库中。

Table View

派生输出

名称说明数据类型
out_dataset

已更新的输入数据集。

表视图

代码示例

EnableAttachments 示例 1(Python 窗口)

以下代码片段说明了如何在 Python 窗口中使用 EnableAttachments 工具。

import arcpy
arcpy.EnableAttachments_management(r"C:\Data\City.gdb\Parcels")
EnableAttachments 示例 2(独立脚本)

以下脚本说明了如何在独立脚本中使用 EnableAttachments 工具。

"""
Example: You have a folder of digital photographs of vacant homes; the photos
         are named according to the ParcelID of the house in the picture. You'll 
         add these photos to a parcel feature class as attachments.
"""
import csv
import arcpy
import os
input = r"C:\Data\City.gdb\Parcels"
inputField = "ParcelID"
matchTable = r"C:\Data\matchtable.csv"
matchField = "ParcelID"
pathField = "Picture" 
picFolder = r"C:\Pictures"
# Create a new Match Table .csv file
writer = csv.writer(open(matchTable, "wb"), delimiter=",")
# Write a header row (the table will have two columns: ParcelID and Picture)
writer.writerow([matchField, pathField])
# Iterate through each picture in the directory and write a row to the table
for file in os.listdir(picFolder):
    if str(file).find(".jpg") > -1:
        writer.writerow([str(file).replace(".jpg", ""), file])
del writer
# The input feature class must first be GDB attachments enabled
arcpy.EnableAttachments_management(input)
# Use the match table with the Add Attachments tool
arcpy.AddAttachments_management(input, inputField, matchTable, matchField, 
                                pathField, picFolder)

许可信息

  • Basic: 否
  • Standard: 是
  • Advanced: 是

相关主题