<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ArcMap 10.3 - Hyperlink Script to Open Shapefile in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcmap-10-3-hyperlink-script-to-open-shapefile/m-p/60252#M4813</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;before I look any further&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt;"&gt;fc = "C:\GIS_Data\Bathymetry\Global"&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;won't work, since backslashes are interpreted as escape characters in python, you have to get it into raw notation by putting that ever-so-little-but-important &lt;STRONG&gt;r&lt;/STRONG&gt; in front of the path ...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;fc = r"C:\GIS_Data\Bathymetry\Global"&amp;nbsp; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 01 Dec 2015 13:54:22 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2015-12-01T13:54:22Z</dc:date>
    <item>
      <title>ArcMap 10.3 - Hyperlink Script to Open Shapefile</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-10-3-hyperlink-script-to-open-shapefile/m-p/60249#M4810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm new to python and need some help please...&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp; The Index.shp has an attribute field called &lt;STRONG&gt;File_Name&lt;/STRONG&gt; with the shapefile name to be opened.&lt;/P&gt;&lt;P&gt;I was able to get some information online, but I still can't figure out how to get it to work.&amp;nbsp; Any help would be greatly appreciated...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's my code to far:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt;"&gt;import arcpy&lt;/STRONG&gt;&lt;/P&gt;&lt;H1&gt;&lt;/H1&gt;&lt;H1&gt;&lt;SPAN style="color: #3334ca;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;#get the current map document&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/H1&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt;"&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;H1&gt;&lt;/H1&gt;&lt;H1&gt;&lt;SPAN style="color: #3334ca;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;#set the directory to bathy shapefiles&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/H1&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt;"&gt;fc = "C:\GIS_Data\Bathymetry\Global"&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;H1&gt;&lt;/H1&gt;&lt;H1&gt;&lt;SPAN style="color: #3334ca;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;#get the data frame&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/H1&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt;"&gt;df = arcpy.mapping.ListDataFrames(mxd,"*")[0]&lt;/STRONG&gt;&lt;/P&gt;&lt;H1&gt;&lt;/H1&gt;&lt;H1&gt;&lt;SPAN style="color: #3334ca;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;#create a new layer - [File_Name] = bathy shapefile name&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/H1&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt;"&gt;bathy_file = (fc+ [File_Name] +'.shp')&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt;"&gt;newlayer = arcpy.mapping.Layer(bathy_file)&lt;/STRONG&gt;&lt;/P&gt;&lt;H1&gt;&lt;/H1&gt;&lt;H1&gt;&lt;SPAN style="color: #3334ca;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;#add the layer to the map at the bottom of the TOC in data frame 0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/H1&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt;"&gt;arcpy.mapping.AddLayer(df, newlayer,"AUTO_ARRANGE")&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Apr 2015 18:29:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-10-3-hyperlink-script-to-open-shapefile/m-p/60249#M4810</guid>
      <dc:creator>HeidiHinz</dc:creator>
      <dc:date>2015-04-22T18:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap 10.3 - Hyperlink Script to Open Shapefile</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-10-3-hyperlink-script-to-open-shapefile/m-p/60250#M4811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Couple things I see quickly...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you use Windows path separators, either use two instead of one or, my preference, precede the string with r&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;fc = "C:\GIS_Data\Bathymetry\Global" &lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;change to...&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;fc = r"C:\GIS_Data\Bathymetry\Global" &lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;c = "C:\\GIS_Data\\Bathymetry\\Global" &lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't see where you're getting [File_Name]. It should be set to a variable when you do get it. You need code to get this value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There's also no path separator between the directory and the file name in&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;&lt;STRONG&gt;bathy_file = (fc+ [File_Name] +'.shp')&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;instead,&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;&lt;STRONG&gt;bathy_file = (fc+ '\\' + [File_Name] +'.shp')&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;or&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;&lt;STRONG&gt;import os&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;&lt;STRONG&gt;bathy_file = os.path.join(fc, [File_Name]) + '.shp'&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Didn't really go through the rest of the code, but that's a start.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Apr 2015 18:53:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-10-3-hyperlink-script-to-open-shapefile/m-p/60250#M4811</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2015-04-22T18:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap 10.3 - Hyperlink Script to Open Shapefile</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-10-3-hyperlink-script-to-open-shapefile/m-p/60251#M4812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you ever get this code to work properly? I am trying to figure out how to do the same thing. Any and all advice is welcomed! Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Dec 2015 13:50:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-10-3-hyperlink-script-to-open-shapefile/m-p/60251#M4812</guid>
      <dc:creator>MikeMcGibney</dc:creator>
      <dc:date>2015-12-01T13:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap 10.3 - Hyperlink Script to Open Shapefile</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-10-3-hyperlink-script-to-open-shapefile/m-p/60252#M4813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;before I look any further&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt;"&gt;fc = "C:\GIS_Data\Bathymetry\Global"&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;won't work, since backslashes are interpreted as escape characters in python, you have to get it into raw notation by putting that ever-so-little-but-important &lt;STRONG&gt;r&lt;/STRONG&gt; in front of the path ...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;fc = r"C:\GIS_Data\Bathymetry\Global"&amp;nbsp; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Dec 2015 13:54:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-10-3-hyperlink-script-to-open-shapefile/m-p/60252#M4813</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-12-01T13:54:22Z</dc:date>
    </item>
  </channel>
</rss>

