<?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: find Workspace based on MXD in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/find-workspace-based-on-mxd/m-p/346004#M27132</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;you should include a "findAndReplaceWorkspacePaths" method on the "CURRENT" map document. If you acquire the path to the .mxd, you could use that within the Replace portion of the findAndReplaceWorkspacePaths, and set the workspace to the same relative path as the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jim&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 Jun 2012 13:36:36 GMT</pubDate>
    <dc:creator>JimCousins</dc:creator>
    <dc:date>2012-06-07T13:36:36Z</dc:date>
    <item>
      <title>find Workspace based on MXD</title>
      <link>https://community.esri.com/t5/python-questions/find-workspace-based-on-mxd/m-p/346003#M27131</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to make a script a bit more friendly by removing the need for a user to manually alter the directory location of a workspace.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is it possible to read something in arcpy.mapping.MapDocument("CURRENT") so that all a person has to do is open the MXD of the project and run the script and the software will find the relevant directories within the appropriate MBD&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2012 13:15:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-workspace-based-on-mxd/m-p/346003#M27131</guid>
      <dc:creator>AnthonyTimpson2</dc:creator>
      <dc:date>2012-06-07T13:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: find Workspace based on MXD</title>
      <link>https://community.esri.com/t5/python-questions/find-workspace-based-on-mxd/m-p/346004#M27132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;you should include a "findAndReplaceWorkspacePaths" method on the "CURRENT" map document. If you acquire the path to the .mxd, you could use that within the Replace portion of the findAndReplaceWorkspacePaths, and set the workspace to the same relative path as the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jim&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2012 13:36:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-workspace-based-on-mxd/m-p/346004#M27132</guid>
      <dc:creator>JimCousins</dc:creator>
      <dc:date>2012-06-07T13:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: find Workspace based on MXD</title>
      <link>https://community.esri.com/t5/python-questions/find-workspace-based-on-mxd/m-p/346005#M27133</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;you should include a "findAndReplaceWorkspacePaths" method on the "CURRENT" map document. If you acquire the path to the .mxd, you could use that within the Replace portion of the findAndReplaceWorkspacePaths, and set the workspace to the same relative path as the map.&lt;BR /&gt;Regards,&lt;BR /&gt;Jim&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This sounds like a fantastic idea, being of limited skills, where would I begin? could you help with some pseudocode? I'd love the challenge of sorting out the actual code, but some hints on directions i should start plodding would be super &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for your help&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2012 13:53:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-workspace-based-on-mxd/m-p/346005#M27133</guid>
      <dc:creator>AnthonyTimpson2</dc:creator>
      <dc:date>2012-06-07T13:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: find Workspace based on MXD</title>
      <link>https://community.esri.com/t5/python-questions/find-workspace-based-on-mxd/m-p/346006#M27134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To get the mxd path.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;mxd = arcpy.mapping.MapDocument("current") mxd_path = mxd.filePath&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2012 15:04:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-workspace-based-on-mxd/m-p/346006#M27134</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-06-07T15:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: find Workspace based on MXD</title>
      <link>https://community.esri.com/t5/python-questions/find-workspace-based-on-mxd/m-p/346007#M27135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I am trying to make a script a bit more friendly by removing the need for a user to manually alter the directory location of a workspace.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's a shortcut to Jim's approach: if you provide layers from the mxd as arguments to your tool instead of dataset paths, &lt;/SPAN&gt;&lt;STRONG&gt;and&lt;/STRONG&gt;&lt;SPAN&gt; set up the mxd to use relative paths, you don't have to worry about paths at all. Once you have the layer inside the script, you can use &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;arcpy.Describe(lyr).catalogPath&lt;/SPAN&gt;&lt;SPAN&gt; to get its full path if you need to locate the workspace.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you would rather use full dataset paths instead of layers as script parameters, here's the rest of Mathew's method to the next step of finding the folder where the current map document lives:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os
mxd = arcpy.mapping.MapDocument("current")
mxd_path = mxd.filePath
mxd_dir = os.path.dirname(mxd_path)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It may be easier to help you if you provided some information about what the script does, for example, what you are doing with the workspace path once you get it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:17:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-workspace-based-on-mxd/m-p/346007#M27135</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T16:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: find Workspace based on MXD</title>
      <link>https://community.esri.com/t5/python-questions/find-workspace-based-on-mxd/m-p/346008#M27136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can run a script from outside ArcGIS. ArcGIS has to be installed of course.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This makes it maybe even easier/faster for the user.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jun 2012 08:37:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-workspace-based-on-mxd/m-p/346008#M27136</guid>
      <dc:creator>FabianBlau</dc:creator>
      <dc:date>2012-06-08T08:37:34Z</dc:date>
    </item>
  </channel>
</rss>

