HowTo:  Add hyperlinks to files that could be located in several subfolders

相关信息
Article ID: 41382
Software:
ArcGIS - ArcEditor 10
ArcGIS - ArcInfo 10
ArcGIS - ArcView 10
ArcGIS for Desktop Advanced 10.1, 10.2
ArcGIS for Desktop Standard 10.1, 10.2
ArcGIS for Desktop Basic 10.1, 10.2
Platforms:
Windows XP, Server 2003, Vista, Server 2008, Windows 7, Windows 8, Server 2012, Server 2008 R2

问题描述
Sometimes documents that must be hyperlinked to features are organized into several subfolders. This is typically done to organize large amounts of data into more manageable smaller folders. One challenge with organizing documents in this way is that it can create confusion when trying to hyperlink features to documents that could be in any of the subfolders of a parent directory. The following workflow is one method to recursively iterate through a directory to find and display documents that are associated with a feature, all through a Python script.
已邀请:

EsriSupport

赞同来自:

解决方案
In this example, the parent directory is called 'Parcels', but there are several subfolders underneath, breaking the Parcels down by zip code. This was done to better organize the data, but can cause confusion when creating hyperlinks in ArcMap. The hyperlinked file is a .jpeg image of the front of the property, and is named by using the Parcel ID.

  1. Add the feature class to ArcMap, and open the layer properties. Right-click the layer and click Properties.
  2. Click the Display tab. Under Hyperlinks, select the 'Support Hyperlinks using field' checkbox, click the 'Script' radio button and click Edit.
  3. At the bottom of the HyperLink Script dialog, select Python as the Parser.
  4. Use some Python code, similar to the following to recursively walk through a directory and find the associated Parcel image: import webbrowser, os

import webbrowser, os
def OpenLink([ParcelID]):
for r,d,f in os.walk(r"\\serverName\Parcels"):
for image in f:
if image.startswith(str([ParcelID])):
webbrowser.open(os.path.join(r,image))
return

5.Click OK to close the Hyperlink Script and Layer Properties dialog boxes.
6.On the Tools toolbar, click the Hyperlink button
, and click on a parcel in the map. If there is a picture associated with this parcel, it opens in whatever application the file type is associated with (by default, in Windows, a .jpeg file opens in Windows Photo Viewer).

创建及修改时间
Created: 7/2/2013

Last Modified: 10/9/2013
原文链接
http://support.esri.com/en/kno ... 41382

要回复问题请先登录注册