<?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: arcpy.mapping.MapDocument (using &amp;quot;current&amp;quot; vs. file path) in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492074#M38563</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes I have the mxd open when I am running that code, and I did not know using the filepath method won't be reflected in the open ArcMap session. Thanks for that!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My only concern is that I need to publish the result to a web service, and I only know how to do that in ArcMap using the geoprocessing result window. From what I've tried, if the layers do not appear in the TOC in an ArcMap session, the outputs in the web service do not appear in the MapServer. Any tips for this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Aug 2015 04:18:46 GMT</pubDate>
    <dc:creator>MichaelKozub</dc:creator>
    <dc:date>2015-08-13T04:18:46Z</dc:date>
    <item>
      <title>arcpy.mapping.MapDocument (using "current" vs. file path)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492070#M38559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN class="s1"&gt;Question for the Python folks.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="s1"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s1"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;I'm trying to add a feature class from my scratch .gdb and have been successful using arcpy.mapping.addLayer. I'm adding the feature class to the mxd which is set to the following:&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s1"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;STRONG&gt;&lt;SPAN class="s1"&gt;mxd = arcpy.mapping.MapDocument("current")&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s1"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;The problem is I'm trying to publish a script tool to a web service, and I know I cannot use "CURRENT" so instead I use the file path of my MXD. While the script tool works, creates my feature class in the scratch .gdb, it does not automatically add the feature class to my TOC as the above line of code does.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;Here's what I'm changing it to instead:&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;STRONG&gt;&lt;SPAN class="s1"&gt;mxd = arcpy.mapping.MapDocument("C:\\users\\testUser\\desktop\\testMap.mxd")&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;The only difference in the entire script is where I'm changing the MXD path. Am I doing this wrong? &lt;/SPAN&gt;&lt;SPAN class="s1"&gt;Any suggestions or recommendations?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 02:31:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492070#M38559</guid>
      <dc:creator>MichaelKozub</dc:creator>
      <dc:date>2015-08-13T02:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument (using "current" vs. file path)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492071#M38560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;did you make a feature layer from the feature class?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/make-feature-layer.htm" rel="nofollow" target="_blank"&gt;http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/make-feature-layer.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Then do you add it to the project?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-mapping/addlayer.htm" rel="nofollow" target="_blank"&gt;http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-mapping/addlayer.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;see the code snippet in the latter link&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 03:50:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492071#M38560</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-08-13T03:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument (using "current" vs. file path)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492072#M38561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have the mxd open when you run that code? Are you expecting changes you make to the mxd file on disk to appear in the currently open ArcMap session?&amp;nbsp; Are you calling mxd.save()?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically "CURRENT" is for interacting with the currently open ArcMap session.&amp;nbsp; arcpy.mapping.MapDocument(filepath) is for interacting with an mxd file &lt;EM&gt;on disk&lt;/EM&gt;. If you have the mxd file open, any changes you make to the file won't be reflected in the open ArcMap session.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 03:56:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492072#M38561</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2015-08-13T03:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument (using "current" vs. file path)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492073#M38562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Basically I am creating a feature layer from the {where_clause} below, then copying that feature layer into the gdb, hence where the feature class comes into play (check the bold print below). Does that make sense?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) MakeFeatureLayer_management (in_features, out_layer, {where_clause}, {workspace}, {field_info})&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I am copying the feature layer to the scratch gdb&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12.8000001907349px;"&gt;2) CopyFeatures_management (in_features, &lt;STRONG&gt;out_feature_class&lt;/STRONG&gt;, {config_keyword}, {spatial_grid_1}, {spatial_grid_2}, {spatial_grid_3})&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12.8000001907349px;"&gt;Then finally I am adding it to the map.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12.8000001907349px;"&gt;3) AddLayer (data_frame, add_layer, {add_position})&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12.8000001907349px;"&gt;I'll try to post the code once I'm back on my work computer.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 04:09:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492073#M38562</guid>
      <dc:creator>MichaelKozub</dc:creator>
      <dc:date>2015-08-13T04:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument (using "current" vs. file path)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492074#M38563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes I have the mxd open when I am running that code, and I did not know using the filepath method won't be reflected in the open ArcMap session. Thanks for that!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My only concern is that I need to publish the result to a web service, and I only know how to do that in ArcMap using the geoprocessing result window. From what I've tried, if the layers do not appear in the TOC in an ArcMap session, the outputs in the web service do not appear in the MapServer. Any tips for this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 04:18:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492074#M38563</guid>
      <dc:creator>MichaelKozub</dc:creator>
      <dc:date>2015-08-13T04:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument (using "current" vs. file path)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492075#M38564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is your end goal? Using arcpy.mapping.MapDocument has pretty limited use in a GP Service. Its mainly good for printing and exporting. If you're trying to use this workflow to update a map you have locally...well I dont see the connection. If you can explain what you want to do (not how you're trying to do it), maybe someone can suggest a workflow.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 13:22:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492075#M38564</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2015-08-13T13:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument (using "current" vs. file path)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492076#M38565</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Hey Kevin thanks for the response. I originally posted my end goal in another thread, but I'll copy and paste it here as well.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;A href="https://community.esri.com/message/543162"&gt;Web Service - Invalid return value // Outputs not showing up in TOC&lt;/A&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-right: 6px; font-size: 20px; font-family: 'Helvetica Neue Notes', sans-serif; color: #333333;"&gt;Here's the goal:&lt;/P&gt;&lt;P style="margin: 0 6px 0 0; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Pass through anywhere from 1-4 input parameters into a web service, and get the same number of outputs as inputs. These outputs will all be line features.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-right: 6px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;In Python I’m basically creating a feature layer and then copying that into a scratch .gdb. In ArcMap I created a script tool to have 4 optional string inputs and 4 optional feature-class outputs respectively. When running the script in the python window, or the script as a tool in ArcMap, it works and performs as I’d expect. I can pass 1, 2, 3, or 4 parameters and I’ll get the proper amount of outputs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-right: 6px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;Problem I:&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-right: 6px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;If I don’t set the output parameters to the scratch gdb in the script tool, the lines do not automatically show up in the table of contents.&lt;/STRONG&gt; For example, the first output parameter will be set to %scratchfolder%\\Scratch.gdb\\line0. They still show up in this scratch gdb because I defined that in the script, but for some reason aren't automatically appearing in the TOC.&lt;/P&gt;&lt;P style="margin-right: 6px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&amp;nbsp; &lt;/P&gt;&lt;P style="margin-right: 6px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;Problem II:&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-right: 6px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;The web service only seems to work when each input has a value, but when I leave one of the four inputs empty, I get an 'esriJobMessageTypeError. Invalid return value: c:\…’ response.&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-right: 6px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;P style="margin-right: 6px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;Any suggestions on how to go about this? Again here’s the problem. The script tool works in ArcMap with 1, 2, 3, or 4 inputs (this is what I want the web service to do!). The web service only works when all 4 inputs are satisfied. I can post screenshots and parts of my script if needed... Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-right: 6px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;-Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 14:21:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492076#M38565</guid>
      <dc:creator>MichaelKozub</dc:creator>
      <dc:date>2015-08-13T14:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument (using "current" vs. file path)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492077#M38566</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, your 2nd problem. GP Services are very strict with their input and output params. Optional output params in a GP Service is well........ not straight forward. Outputs get hardcoded with a gp service. When you run your tool in ArcMap before publishing, this sets up the "footprint" if you will of what the service will be like. So if you had 3 outputs when you ran in AM, once you publish it the service will want 3 outputs. Not 2, not 4, but 3. So anytime you start playing the optional game you're going to get into trouble. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the 1st issue - I dont really understand what you're saying here. I can only guess this is a "tool problem", that is how the tool has been setup/configured. You're having the problem here before publishing? Or this is the published gp service? You're expecting to get the result back from the gp service and it gets added to ArcMap? As long as the output is a featureclass in the tool, yes it should be automatically added.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 14:49:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492077#M38566</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2015-08-13T14:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument (using "current" vs. file path)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492078#M38567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Let's stick with problem II for now. Knowing I'll be passing one-four parameters into the service, are you saying I should set all four inputs to required instead of optional? And then doing the same for the outputs?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any other alternatives to using a GP service? In the most basic form all I need to do is draw four distinct lines on a map.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 15:11:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492078#M38567</guid>
      <dc:creator>MichaelKozub</dc:creator>
      <dc:date>2015-08-13T15:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument (using "current" vs. file path)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492079#M38568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could you output 1 featureclass, but have anywhere between 1-4 features/records in that FC? Build a layerfile that has symbology set for 4 features based on a given field. Then in the script, generate those features and in the script tool output parameter symbology, use the layer file. After you publish the service and run it in arcmap, it'll draw the features based on that layerfile.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 15:23:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492079#M38568</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2015-08-13T15:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument (using "current" vs. file path)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492080#M38569</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So I ended up creating four feature classes, then merging them into one feature class at the end per your suggestion. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Additionally, I had to add a field and calculate the field to make each of the records in each of the feature classes unique, but anyways I got a desired web service to do what I needed it to do. The service&lt;SPAN style="line-height: 1.5;"&gt; now accepts anywhere from 1-4 parameters and always has 1 output which is symbolized by a layer file. Thanks for giving me another approach to solve this, Kevin.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5;"&gt;Thanks to everybody else who chimed in as well. All of this is great!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 23:45:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-using-quot-current-quot/m-p/492080#M38569</guid>
      <dc:creator>MichaelKozub</dc:creator>
      <dc:date>2015-08-13T23:45:31Z</dc:date>
    </item>
  </channel>
</rss>

