添付ファイルの有効化 (Enable Attachments) (データ管理)

サマリー

ジオデータベース フィーチャクラスまたはテーブルの添付ファイルを有効化します。 このツールは、必要な添付ファイル リレーションシップ クラスと、添付ファイルのファイルを内部的に格納する添付ファイル テーブルを作成します。

添付ファイル ジオプロセシング ツールの操作の詳細

使用法

  • 入力データセットをエンタープライズ データセットから取得する場合、データの所有者として確立されたデータベース コネクションから取得する必要があります。

  • [添付ファイルの追加 (Add Attachments)] ツールを使用して添付ファイルを追加する前に、このツールを使用して添付ファイルを有効化する必要があります。

  • ジオデータベース フィーチャクラスまたはテーブルで添付ファイルがすでに有効化されている場合は、警告メッセージが表示され、処理は実行されません。

  • レプリカ トラッキングが有効で、履歴管理が有効なバージョン非対応データセットは、添付ファイル テーブルで履歴管理とレプリカ トラッキングが有効になります。

  • ブランチ バージョン対応のデータセットは、ブランチ バージョン対応登録されず、添付ファイル テーブルでレプリカ トラッキングが自動的に有効になります。 これは、[バージョン対応登録 (Register As Versioned)] ツールと [レプリカ トラッキングの有効化 (Enable Replica Tracking)] ツールを使用して手動で処理することができます。

パラメーター

ラベル説明データ タイプ
入力データセット

添付ファイルを有効化するジオデータベース テーブルまたはフィーチャクラス。 入力は、バージョン 10 以降のジオデータベースに存在している必要があります。

Table View

派生した出力

ラベル説明データ タイプ
更新された入力データセット

更新された入力データセット。

Table View

arcpy.management.EnableAttachments(in_dataset)
名前説明データ タイプ
in_dataset

添付ファイルを有効化するジオデータベース テーブルまたはフィーチャクラス。 入力は、バージョン 10 以降のジオデータベースに存在している必要があります。

Table View

派生した出力

名前説明データ タイプ
out_dataset

更新された入力データセット。

Table View

コードのサンプル

EnableAttachments の例 1 (Python ウィンドウ)

次のコード スニペットは、Python ウィンドウで EnableAttachments 関数を使用する方法を示しています。

import arcpy
arcpy.management.EnableAttachments(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.management.EnableAttachments(input)

# Use the match table with the Add Attachments tool
arcpy.management.AddAttachments(input, inputField, matchTable, matchField, 
                                pathField, picFolder)

ライセンス情報

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

関連トピック