<?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: How to add the model output to a new mapdocument or replace the existing table of content?  in ModelBuilder Questions</title>
    <link>https://community.esri.com/t5/modelbuilder-questions/how-to-add-the-model-output-to-a-new-mapdocument/m-p/805638#M2161</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This requires a little Python scripting using the Calculate Value tool. You need to write a function (placed in the Calculate Value code block) that opens a template MXD and sets all the new paths using the arcpy.mapping module. The inputs to the function would be the template MXD (this could be a model element) and the path to your output gdb. The calculate value expression would be something like:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;save_mxd&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"%mxd_template%"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"%output_mxd_folder%"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&amp;nbsp; r&lt;SPAN class="string token"&gt;"%output_gdb%"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;A class="link-titled" href="http://pro.arcgis.com/en/pro-app/tool-reference/modelbuilder-toolbox/calculate-value.htm" title="http://pro.arcgis.com/en/pro-app/tool-reference/modelbuilder-toolbox/calculate-value.htm"&gt;Calculate Value—Tools | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/introduction-to-arcpy-mapping.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/introduction-to-arcpy-mapping.htm"&gt;Introduction to arcpy.mapping—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 24 Nov 2017 17:28:07 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2017-11-24T17:28:07Z</dc:date>
    <item>
      <title>How to add the model output to a new mapdocument or replace the existing table of content?</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/how-to-add-the-model-output-to-a-new-mapdocument/m-p/805637#M2160</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to create a tool using model builder in Arcmap 10.4 which will allow the user to draw a polygon interactively and clip all layers within the polygon. The clipped layers will then be saved in an output file geodatabase containing a featuredataset having same name as the original layers. My input&amp;nbsp;layers&amp;nbsp;are from a file geodatabase containing featuredataset. My idea is to add the output to a new map document automatically or&amp;nbsp; replace the existing TOC. I am attaching my tool, input and output file geodatabase. I will appreciate any kind of help regarding the Problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rimon&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Nov 2017 07:48:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/how-to-add-the-model-output-to-a-new-mapdocument/m-p/805637#M2160</guid>
      <dc:creator>Attarabbi</dc:creator>
      <dc:date>2017-11-24T07:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to add the model output to a new mapdocument or replace the existing table of content?</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/how-to-add-the-model-output-to-a-new-mapdocument/m-p/805638#M2161</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This requires a little Python scripting using the Calculate Value tool. You need to write a function (placed in the Calculate Value code block) that opens a template MXD and sets all the new paths using the arcpy.mapping module. The inputs to the function would be the template MXD (this could be a model element) and the path to your output gdb. The calculate value expression would be something like:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;save_mxd&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"%mxd_template%"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"%output_mxd_folder%"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&amp;nbsp; r&lt;SPAN class="string token"&gt;"%output_gdb%"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;A class="link-titled" href="http://pro.arcgis.com/en/pro-app/tool-reference/modelbuilder-toolbox/calculate-value.htm" title="http://pro.arcgis.com/en/pro-app/tool-reference/modelbuilder-toolbox/calculate-value.htm"&gt;Calculate Value—Tools | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/introduction-to-arcpy-mapping.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/introduction-to-arcpy-mapping.htm"&gt;Introduction to arcpy.mapping—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Nov 2017 17:28:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/how-to-add-the-model-output-to-a-new-mapdocument/m-p/805638#M2161</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2017-11-24T17:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to add the model output to a new mapdocument or replace the existing table of content?</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/how-to-add-the-model-output-to-a-new-mapdocument/m-p/805639#M2162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for your reply. I am new to python. I tried to evaluate the expression above as you stated within the calculate value. But it takes save_mxd as a variable I think and It gives error result. Can you look at it and see what is the problem? Thanks in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/385010_pastedImage_1.png" style="width: 620px; height: 231px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Nov 2017 15:34:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/how-to-add-the-model-output-to-a-new-mapdocument/m-p/805639#M2162</guid>
      <dc:creator>Attarabbi</dc:creator>
      <dc:date>2017-11-27T15:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to add the model output to a new mapdocument or replace the existing table of content?</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/how-to-add-the-model-output-to-a-new-mapdocument/m-p/805640#M2163</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you have nothing in the expression box you need to make it a function and usewhat Curtis supplied should go in the code box.&amp;nbsp; your line should go in the expression box to call the function which is names save_mxd&lt;/P&gt;&lt;P&gt;Calculate Value—Tools | ArcGIS Desktop look at the provided image from the help&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;UL&gt;&lt;LI&gt;&lt;IMG alt="Using model variable in Calculate Value tool" src="http://pro.arcgis.com/en/pro-app/tool-reference/modelbuilder-toolbox/GUID-BD0B0C35-637E-498D-9F84-A577AF52551A-web.png" title="Using model variable in Calculate Value tool" /&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Nov 2017 21:56:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/how-to-add-the-model-output-to-a-new-mapdocument/m-p/805640#M2163</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-11-27T21:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to add the model output to a new mapdocument or replace the existing table of content?</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/how-to-add-the-model-output-to-a-new-mapdocument/m-p/805641#M2164</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for your reply. I tried to make a function in calculate value tool but did not succeed. Instead if I try to elaborate and create a script in python&amp;nbsp;that will take a geodatabase/featuredataset as input and place the featuredataset in TOC of a new mapdocument. My intension is to use the same dataframe&amp;nbsp;from the current map document. My Idea is like this,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Import module &lt;BR /&gt;import os&lt;BR /&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt; &lt;BR /&gt; # Set input parameter (I want to connect this script to the model output which is a geodatabase and &lt;SPAN&gt;param0 will take the .gdb as input&lt;/SPAN&gt;)&lt;BR /&gt;def getParameterInfo(self):&lt;BR /&gt;param0 = arcpy.Parameter(&lt;BR /&gt;displayName="Input Geodata",&lt;BR /&gt;name="in_workspace",&lt;BR /&gt;datatype="DEGeodatasetType",&lt;BR /&gt;parameterType="Required",&lt;BR /&gt;direction="Input")&lt;BR /&gt;return param0&lt;BR /&gt; &lt;BR /&gt;# Set environment&lt;BR /&gt;arcpy.env.workspace = ("param0")&amp;nbsp;&amp;nbsp;&lt;BR /&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;BR /&gt; &lt;BR /&gt;# Copy the dataframe from current mxd to a new mxd and add the inputted gdb to map document. &lt;BR /&gt; &lt;BR /&gt;for df in arcpy.mapping.ListDataFrames(mxd):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; for ds in arcpy.mapping.ListDataset(feature_type='feature')&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for fc in arcpy.mapping.ListFeatureClasses()&amp;nbsp;&lt;BR /&gt;mxd.saveACopy(r"C:\Users\attrab01\Downloads\PK\\" + "Project"+ ".mxd")&lt;BR /&gt;del mxd1&lt;BR /&gt; &lt;BR /&gt;# Open the new mxd automatic&lt;BR /&gt; &lt;BR /&gt;os.startfile(r"C:\Users\attrab01\Downloads\PK\\" + "Project" + ".mxd")&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;This is a very basic and logical structure of my desired output. I would really appreciate if you can give me an exaple how to compile the code in python. Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Dec 2017 07:00:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/how-to-add-the-model-output-to-a-new-mapdocument/m-p/805641#M2164</guid>
      <dc:creator>Attarabbi</dc:creator>
      <dc:date>2017-12-04T07:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to add the model output to a new mapdocument or replace the existing table of content?</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/how-to-add-the-model-output-to-a-new-mapdocument/m-p/805642#M2165</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting"&gt;&lt;STRONG&gt;code formatting the basics ++&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;To get the code into a readable format first.&amp;nbsp; Your code should be using parameters rather than hard coded, like your references to the folder location.&amp;nbsp; You can make a script tool for use in ArcToolbox possibly, or simply use a python IDE to run the script.&amp;nbsp; I am guessing that you did neither or you would have reported error message or it would have worked&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Dec 2017 07:20:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/how-to-add-the-model-output-to-a-new-mapdocument/m-p/805642#M2165</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-12-04T07:20:50Z</dc:date>
    </item>
  </channel>
</rss>

