使用方法
语法
arcpy.management.EnableAttachments(in_dataset)
参数 | 说明 | 数据类型 |
in_dataset | 将启用附件的地理数据库表或要素类。输入的表或要素类必须处于 10 或更高版本的地理数据库中。 | Table View |
派生输出
名称 | 说明 | 数据类型 |
out_dataset | 已更新的输入数据集。 | 表视图 |
代码示例
以下代码片段说明了如何在 Python 窗口中使用 EnableAttachments 工具。
import arcpy
arcpy.EnableAttachments_management(r"C:\Data\City.gdb\Parcels")
以下脚本说明了如何在独立脚本中使用 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: 是