ArcMap 10.3 - Hyperlink Script to Open Shapefile

Discussion created by Hydie03 on Apr 22, 2015
Latest reply on Dec 1, 2015 by Dan_Patterson

I'm new to python and need some help please... 


I have a shapefile (Index.shp) that is used as an index for the world splitting it into 264 areas (polygon). I'm trying to create a python script (for the ArcMap Hyperlink Scrip section of this Index.shp) that will add another shapefile to the current ArcMap project based on the polygon the user has clicked on with the hyperlink tool.  The Index.shp has an attribute field called File_Name with the shapefile name to be opened.

I was able to get some information online, but I still can't figure out how to get it to work.  Any help would be greatly appreciated...


Here's my code to far:


import arcpy

#get the current map document

mxd = arcpy.mapping.MapDocument("CURRENT") 

#set the directory to bathy shapefiles

fc = "C:\GIS_Data\Bathymetry\Global" 

#get the data frame

df = arcpy.mapping.ListDataFrames(mxd,"*")[0]

#create a new layer - [File_Name] = bathy shapefile name

bathy_file = (fc+ [File_Name] +'.shp')

newlayer = arcpy.mapping.Layer(bathy_file)

#add the layer to the map at the bottom of the TOC in data frame 0

arcpy.mapping.AddLayer(df, newlayer,"AUTO_ARRANGE")