ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Enable Attachments

  • Summary
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Enables attachments on a geodatabase feature class or table. The tool creates the necessary attachment relationship class and attachment table that will store attachment files internally.

  • Learn more about geodatabase attachments
  • Learn more about working with the Attachments geoprocessing tools

Usage

  • If the input dataset is from an enterprise geodatabase, it must be from a database connection established as the data owner.

  • Attachments must first be enabled using this tool before they can be added using the Add Attachments tool.

  • If the geodatabase feature class or table already has attachments enabled, a warning message will appear and no processing will occur.

Syntax

EnableAttachments(in_dataset)
ParameterExplanationData Type
in_dataset

The geodatabase table or feature class for which attachments will be enabled. The input must be in a version 10 or later geodatabase.

Table View

Derived Output

NameExplanationData Type
out_dataset

The updated input dataset.

Table View

Code sample

EnableAttachments example 1 (Python window)

The following code snippet illustrates how to use the EnableAttachments tool in the Python window.

import arcpy
arcpy.EnableAttachments_management(r"C:\Data\City.gdb\Parcels")
EnableAttachments example 2 (stand-alone script)

The following script illustrates how to use the EnableAttachments tool in a stand-alone script.

"""
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)

Environments

  • Current Workspace

Licensing information

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

Related topics

  • An overview of the Attachments toolset
  • Working with the Attachments geoprocessing tools

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2020 Esri. | Privacy | Legal