<?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: Running the Map to KML tool in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89148#M6912</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;After looking at this, this comes back as a single element list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This might be better:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14316414833612913 jive_text_macro" data-renderedposition="92_8_913_16" jivemacro_uid="_14316414833612913" modifiedtitle="true"&gt;&lt;P&gt;mapname = str(mxd.filepath).split('\\')[-1:][0][:-4]&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 May 2015 22:11:57 GMT</pubDate>
    <dc:creator>JeffWard</dc:creator>
    <dc:date>2015-05-14T22:11:57Z</dc:date>
    <item>
      <title>Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89137#M6901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial black,avant garde; font-size: 10pt;"&gt;I am trying to create a script that will apply a symbology layer to the current map, save the map, export the map to KML, and then reapply the original symbology from a layer file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial black,avant garde; font-size: 10pt;"&gt;&lt;STRONG&gt;Apply symbology from layer file:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial black,avant garde; font-size: 10pt;"&gt;&lt;CODE&gt;&lt;SPAN class="c"&gt;# Import system modules&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="kn"&gt;import&lt;/SPAN&gt; &lt;SPAN class="nn"&gt;arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="kn"&gt;from&lt;/SPAN&gt; &lt;SPAN class="nn"&gt;arcpy&lt;/SPAN&gt; &lt;SPAN class="kn"&gt;import&lt;/SPAN&gt; &lt;SPAN class="n"&gt;env&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="c"&gt;# Set the current workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="n"&gt;env&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;workspace&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s"&gt;"file path where layer files are saved"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="c"&gt;# Set layer to apply symbology to&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="n"&gt;inputLayer&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s"&gt;"layer file name"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="c"&gt;# Set layer that output symbology will be based on&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="n"&gt;symbologyLayer&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s"&gt;"feature class within map"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="c"&gt;# Apply the symbology from the symbology layer to the input layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="n"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;ApplySymbologyFromLayer_management&lt;/SPAN&gt; &lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;inputLayer&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;symbologyLayer&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="font-family: arial black,avant garde; font-size: 10pt;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="font-family: arial black,avant garde; font-size: 10pt;"&gt;This part works fine.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial black,avant garde; font-size: 10pt;"&gt;&lt;STRONG&gt;&lt;SPAN class="p"&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;&lt;SPAN class="p"&gt;Save the map:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial black,avant garde;"&gt;&lt;STRONG&gt;&lt;SPAN class="p"&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="font-size: 10pt; font-family: arial black,avant garde;"&gt;&lt;CODE&gt;&lt;SPAN class="c"&gt;# Set up map variable&lt;BR /&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="font-size: 10pt; font-family: arial black,avant garde;"&gt;&lt;CODE&gt;&lt;SPAN class="kwd"&gt;import&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; arcpy&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;mapping &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;as&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; map&lt;BR /&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="font-size: 10pt; font-family: arial black,avant garde;"&gt;&lt;SPAN class="pln"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="font-size: 10pt; font-family: arial black,avant garde;"&gt;&lt;CODE&gt;&lt;SPAN class="pln"&gt;# Set map variable to current mxd&lt;BR /&gt;mxd &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; map&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;MapDocument&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;("CURRENT")&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="font-size: 10pt; font-family: arial black,avant garde;"&gt;&lt;SPAN class="pln"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="font-size: 10pt; font-family: arial black,avant garde;"&gt;&lt;CODE&gt;&lt;SPAN class="pln"&gt;# Save the map document&lt;BR /&gt;mxd&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;save&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;()&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="font-size: 10pt; font-family: arial black,avant garde;"&gt;&lt;SPAN class="pun"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="font-size: 10pt; font-family: arial black,avant garde;"&gt;&lt;SPAN class="pun"&gt;This part works fine.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="font-family: arial black,avant garde; font-size: 10pt;"&gt;&lt;SPAN class="pun"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial black,avant garde; font-size: 10pt;"&gt;&lt;STRONG&gt;&lt;SPAN class="p"&gt;&lt;SPAN class="pun"&gt;Map to KML:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="c" style="font-size: 10pt;"&gt;# Set environment settings&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN class="n"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;env&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;workspace&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s"&gt;"haven't figured this part out yet"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN class="c"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN class="c"&gt;# Set Local Variables&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN class="n"&gt;dataFrame&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s"&gt;'Layers'&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN class="s"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN class="c"&gt;# Sets the KMZ name to be equal to the mxd&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN class="n"&gt;outKML&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;mxd&lt;/SPAN&gt;&lt;SPAN class="p"&gt;&lt;/SPAN&gt;&lt;SPAN class="o"&gt;&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;&lt;/SPAN&gt;&lt;SPAN class="p"&gt;&lt;/SPAN&gt;&lt;SPAN class="o"&gt;+&lt;/SPAN&gt;&lt;SPAN class="s"&gt;'.kmz'&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN class="c"&gt;#Execute MapToKML&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN class="n"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;MapToKML_conversion&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;mxd&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;dataFrame&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;outKML&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;&lt;SPAN class="n"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN class="p"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN class="p"&gt;This is the part that I'm having trouble with.&amp;nbsp; I'm not entirely sure how to correctly construct the Map to KML portion.&amp;nbsp; This script will be run on many different maps and the workspace for each map will be identical to each other with the exception of the map name.&amp;nbsp; I tried to set the workspace to the following path, with no luck:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN class="p"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN class="p"&gt;arcpy.env.workspace = "folder1\folder2\folder3\" + mxd + "\folder4\folder5"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN class="p"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN class="p"&gt;But this results in this error "Parsing error SyntaxError: unexpected character after line continuation character (line 1)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN class="p"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt;"&gt;&lt;SPAN class="p"&gt;Apply symbology from layer file:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt;"&gt;&lt;SPAN class="p"&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN class="p"&gt;Simply a repeat of the previous iteration of the tool with a different layer file.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2015 19:00:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89137#M6901</guid>
      <dc:creator>CoyPotts1</dc:creator>
      <dc:date>2015-05-14T19:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89138#M6902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You want the output set like that, not the workspace, i think?&lt;/P&gt;&lt;P&gt;and the mxd name should be passed as a string&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;output = "&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 13.3333320617676px;"&gt;folder1/folder2/folder3/&lt;/SPAN&gt;"
mxdname = "mystring"
arcpy.&amp;lt;whatever&amp;gt;(output + &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 13.3333320617676px;"&gt;mxdname + "/folder4/folder5/"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:24:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89138#M6902</guid>
      <dc:creator>CarlSunderman</dc:creator>
      <dc:date>2021-12-10T23:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89139#M6903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay, I sort of understand that.&amp;nbsp; And yes, I was playing with other variations and I was getting the error saying that I couldn't mix a string and a map document, but I couldn't figure out how to translate my map document into a string like ymou do in your exaple. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm very green when it comes to Python scripting, so I'm not sure how to correctly answer your question regarding the workspace vs. output.&amp;nbsp; The tool needs to have a workspace in order to know where to save the KML, correct?&amp;nbsp; An alternative, and I think it's what you are showing above, is that you simply create the variables as you show, and then set outKML to equal the concatenation of those variables.&amp;nbsp; So instead of saying save this output in this workspace, you're saying that the output KML equals the entire file path.&amp;nbsp; Am I understanding that correctly?&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In regards to the mxdname = "mystring", can you say mxdname = mxd?&amp;nbsp; Or would that still have it be referencing a map document instead of turning it into a string.&amp;nbsp; I'm just a little unclear on how to take my map document's name and add it into the whole folder path. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2015 20:19:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89139#M6903</guid>
      <dc:creator>CoyPotts1</dc:creator>
      <dc:date>2015-05-14T20:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89140#M6904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An additional question...what IDLE do you use to get the numbered structure next to each line of your code?&amp;nbsp; I have been using the python window within ArcMap just because that's all I know to use, but I don't really like it all that much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And thank you so much for the response!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2015 20:25:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89140#M6904</guid>
      <dc:creator>CoyPotts1</dc:creator>
      <dc:date>2015-05-14T20:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89141#M6905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As far as I can tell, your main problem with:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 13.3333320617676px;"&gt;arcpy.env.workspace = "folder1\folder2\folder3\" + mxd + "\folder4\folder5"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 13.3333320617676px;"&gt;is ending your string with \" which translates to an escaped quotation mark, or literally the symbol ". That part of the string never closes. For paths, you should use r"path\path", or "path/path" or "path\\path".&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; font-size: 13.3333320617676px;"&gt;Furthermore, the easy way to concatenate paths is by using os.path.join, which uses the system path separator to join path strings:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; import os.path
... first_concat = os.path.join(r"C:\folder1\folder2\folder3","someMapName")
... print first_concat
... second_concat = os.path.join(first_concat,r"folder4\folder5")
... print second_concat
... 
C:\folder1\folder2\folder3\someMapName
C:\folder1\folder2\folder3\someMapName\folder4\folder5&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:24:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89141#M6905</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-10T23:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89142#M6906</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/people/curtvprice/blog/2014/09/25/posting-code-blocks-in-the-new-geonet"&gt;Here's how to post code snippets in GeoNet.&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2015 21:13:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89142#M6906</guid>
      <dc:creator>JeffWard</dc:creator>
      <dc:date>2015-05-14T21:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89143#M6907</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay, that is also helpful. I'll go a little deeper into explanation.&amp;nbsp; A sample file path is listed below (renaming the actual folder names for proprietary purposes):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;\\company.local\dfs\dept_name\gis_folder\projects\region\region-state-name-carrier\deliverables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is the full file path that I would be working with.&amp;nbsp; We name the maps identically to the "region-state-name-carrier" naming convention (e.g. "NC-IL-MYHOUSE-VZW").&amp;nbsp; The mxd is saved at this stage of the file path.&amp;nbsp; Once we create a KML output from the mxd, it is saved in the deliverables stage of the file path. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought that since all file paths are identical with the exception of the "region\region-state-name-carrier" portion, I could just make static variables for "\\company.local\dfs\dept_name\gis_folder\projects\" and "\deliverables", and use the map name as the dynamic variable that will change from project to project.&amp;nbsp; Essentially I need to take the map name and convert it to a string.&amp;nbsp; I would take that string and strip out only the first two characters to uses as my "region", and then I would use the whole string as my "region-state-name-carrier" portion.&amp;nbsp; I'll list the potential variables below for a better understanding.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mapname = mxd&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - I haven't figured out how to do this yet.&amp;nbsp; This is where I want to turn my map name into a string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;region = mapname[:2]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - I haven't figured this part out either, but through google I found that this is one way to strip parts of a string apart, I but it wasn't working when tried.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;filePath1 = r"\\company.local\dfs\dept_name\gis_folder\projects\"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;filePath2 = r"\deliverables"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = filePath1 + region + mapname + filePath2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if that doesn't work I am brainstorming and thinking this might work for the workspace:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;workspace = filePath1 + region + mapname + filePath2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = workspace&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm only thinking of this because the arcpy.env.workspace function might not like concatenating the multiple variables...but I really don't know :/.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your input so far! &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2015 21:33:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89143#M6907</guid>
      <dc:creator>CoyPotts1</dc:creator>
      <dc:date>2015-05-14T21:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89144#M6908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Jeff, I will note that for future reference.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2015 21:34:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89144#M6908</guid>
      <dc:creator>CoyPotts1</dc:creator>
      <dc:date>2015-05-14T21:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89145#M6909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14316406062321266 jive_text_macro" data-renderedposition="50_8_913_16" jivemacro_uid="_14316406062321266" modifiedtitle="true"&gt;&lt;P&gt;mapname = str(mxd.filepath).split('\\')[-1:]&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This gets the path of the map document, converts it to a string, splits it by the double backslash and puts the last element in mapname.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited to fix my hasty slicing error.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2015 21:57:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89145#M6909</guid>
      <dc:creator>JeffWard</dc:creator>
      <dc:date>2015-05-14T21:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89146#M6910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;filePath1 = r"\\company.local\dfs\dept_name\gis_folder\projects\"&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;You need to take out the double backslash at the beginning of this if you are going to preface it with r.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2015 22:00:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89146#M6910</guid>
      <dc:creator>JeffWard</dc:creator>
      <dc:date>2015-05-14T22:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89147#M6911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As far as getting the file name,&amp;nbsp; i'm not sure of a real elegant way, but i'm sure there is.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps you could use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000000; font-family: monospace; font-size: 11.3999996185303px;"&gt;import os
&lt;/SPAN&gt;
#os.path.split(path)
head, tail = os.path.split("C:/tmp/myfile.mxd")
#head, tail = os.&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;path.split("//tmp/myfile.mxd)&lt;/SPAN&gt;

&amp;gt;&amp;gt;&amp;gt;print tail
myfile.mxd&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;or something along those lines. then strip off the mxd. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;this would work for&amp;nbsp; "/" as well as "\"&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:24:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89147#M6911</guid>
      <dc:creator>CarlSunderman</dc:creator>
      <dc:date>2021-12-10T23:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89148#M6912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;After looking at this, this comes back as a single element list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This might be better:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14316414833612913 jive_text_macro" data-renderedposition="92_8_913_16" jivemacro_uid="_14316414833612913" modifiedtitle="true"&gt;&lt;P&gt;mapname = str(mxd.filepath).split('\\')[-1:][0][:-4]&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2015 22:11:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89148#M6912</guid>
      <dc:creator>JeffWard</dc:creator>
      <dc:date>2015-05-14T22:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89149#M6913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I haven't had much of an opportunity to test out the suggestions for pulling out the mxd name, but I have a script that runs all the way up to the MapToKML portion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# Name:&amp;nbsp; Map To KML
# Description:&amp;nbsp; This script is used within a model to export the map to a KMZ file for distribution.
# Author:&amp;nbsp; Coy Potts
# Parts: (1) Apply Symbology Layer File, (2) Save mxd, (3) MapToKML tool, (4) Apply Symbology Layer File

# Import system modules
import arcpy
from arcpy import env
import arcpy.mapping as map

# Part 1:
# Apply Symbology Layer File

# Set current workspace
env.workspace = r'\\company.local\dfs\dept_name\1)folder\folder\layerFiles folder'

# Set layer to apply symbology to
inputLayer = r'\\company.local\dfs\dept_name\1)folder\folder\folder\layerFile.lyr'

# Set layer that output symbology will be based on
symbologyLayer = r'DataFrame\FeatureClass'

# Apply the symbology from the symbology layer to the input layer
arcpy.ApplySymbologyFromLayer_management (inputLayer, symbologyLayer)

# Part 2:
# Save the map

# Set the map document to the current map
mxd = map.MapDocument("CURRENT")

# Save the map
mxd.save()

# Part 3:
# Map to KML tool

# Set current workspace
env.workspace = '%saveKML%'

# Set local MapToKML tool variables
inputMap = mxd
outputKML = '%outputKML%' + '.kmz'

# Execute MapToKML
arcpy.MapToKML_converstion(inputMap, outputKML)



&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I went ahead and set the script up to grab two variables that are within a model builder model.&amp;nbsp; The saveKML is the file path to be input by the user, and the outputKML is the name of the KML file, also input by the user.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Originally I set this script up in NotePad, saved as a .txt file, loaded into the ArcMap python window, saved as a .py script.&amp;nbsp; From there I loaded it into a script inside my toolbox and then inserted that script within the model with the two variables.&amp;nbsp; When doing it this way I got an error that said syntax error on line 2, but I couldn't figure out why.&amp;nbsp; So I went and manually entered the entire script into the ArcMap python window piece by piece, and it was all working up to the point executing the MapToKML tool.&amp;nbsp; Once I pressed enter after that line, it kicked back the following error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"Runtime error&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\conversion.py", line 2278, in MapToKML&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e&lt;/P&gt;&lt;P&gt;RuntimeError: Object: Error in executing tool"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Everything up to that point ran just fine.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:24:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89149#M6913</guid>
      <dc:creator>CoyPotts1</dc:creator>
      <dc:date>2021-12-10T23:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89150#M6914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Don't know if this is the whole problem, but "conversion" is spelled wrong. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 05:31:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89150#M6914</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-05-15T05:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89151#M6915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Heh, I do have a t in there &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;. I'll see tomorrow what I get when I take that out. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it's about time to give this a rest for tonight. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 05:59:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89151#M6915</guid>
      <dc:creator>CoyPotts1</dc:creator>
      <dc:date>2015-05-15T05:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89152#M6916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.MapToKML_conversion(inputMap, outputKML)&amp;nbsp;&amp;nbsp;&amp;nbsp; 
Runtime error 
Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;
&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\conversion.py", line 2278, in MapToKML
&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e
RuntimeError: Object: Error in executing tool
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The "t" was only in the version that I had written in NotePad.&amp;nbsp; The code above is what I had typed into the actual ArcMap Python window. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:24:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89152#M6916</guid>
      <dc:creator>CoyPotts1</dc:creator>
      <dc:date>2021-12-10T23:24:24Z</dc:date>
    </item>
    <item>
      <title>Re: Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89153#M6917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I normally hardcode values like inputs and outputs until i get everything working, then start adding the variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would skip using model builder since you have all the python in the above comments to get it working. I personally have never used it&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 14:20:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89153#M6917</guid>
      <dc:creator>CarlSunderman</dc:creator>
      <dc:date>2015-05-15T14:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89154#M6918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unless it's a network path - doh!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 14:27:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89154#M6918</guid>
      <dc:creator>JeffWard</dc:creator>
      <dc:date>2015-05-15T14:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89155#M6919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try using &lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-functions/getparameterastext.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;GetParameterAsText&lt;/A&gt; for your model variables inside your script.&amp;nbsp; Python is interpreting '%saveKML%' as strings.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;env.workspace = arcpy.GetParameterAsText('0')
outputKML = arcpy.GetParameterAsText('1')&lt;SPAN class="string"&gt; + '.kmz'&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:24:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89155#M6919</guid>
      <dc:creator>JeffWard</dc:creator>
      <dc:date>2021-12-10T23:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: Running the Map to KML tool</title>
      <link>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89156#M6920</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would like to get away from it, but it was the only way I could think of to add a dynamic variable that the user could change.&amp;nbsp; I'm getting errors with the code suggestions above to try and strip the file path.&amp;nbsp; I get the following error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; import arcpy
&amp;gt;&amp;gt;&amp;gt; import arcpy.mapping as map
&amp;gt;&amp;gt;&amp;gt; mxd = map.MapDocument("CURRENT")
&amp;gt;&amp;gt;&amp;gt; mapname = str(mxd.filepath).split('\\')[-1:]
Runtime error 
Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;
AttributeError: 'MapDocument' object has no attribute 'filepath'
&amp;gt;&amp;gt;&amp;gt; &lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just as you have suggested, I went ahead and gave literal values in place of the variables and I get the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;... # Part 3:
... # Map to KML tool
... 
... # Set current workspace
... # env.workspace = "C:\Users\cpotts\Desktop\Test_Folders"
... 
... # Set local MapToKML variables
... inputMap = mxd
... outputKML = "output_test.kmz"
... 
... # Execute MapToKML
... arcpy.MapToKML_conversion(inputMap, outputKML)
... 
... 
... 
... 
Runtime error 
Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;string&amp;gt;", line 46, in &amp;lt;module&amp;gt;
&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\conversion.py", line 2278, in MapToKML
&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e
RuntimeError: Object: Error in executing tool&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As per this &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//00120000004p000000" rel="nofollow noopener noreferrer" target="_blank"&gt;LINK&lt;/A&gt; there are 10 conditions that are within the MapToKML tool, and I wonder if they're all required in order for the tool to run.&amp;nbsp; If that is the case, hothw do you configure pyon to simply run with the defaulted value instead of having to set that parameter.&amp;nbsp; When I run the tool manually, the data frame that it selects defaults to the only data frame in our map, which is again named identically to the map document, thus leading to the same issue as stated above where I still need to get the map name into a string so I can use it as a variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suppose I could change our map template to have a static data frame name, which I could then hard code into the script since it would never change, but I don't want to do that unless I have to.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The image below shows the inputs that I use when I manually run the tool.&amp;nbsp; I choose my mxd, it defaults to the only data frame in the map, I name the output file, and then I set the extent properties to match that of one of the feature classes.&amp;nbsp; Every other input I leave as the default value. &lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.JPG" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/100259_Capture.JPG" style="width: 620px; height: 328px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again for all the help guys!&amp;nbsp; I think we're getting closer to a solution &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;.&amp;nbsp; This is the first script that I have ever tried to construct to run ArcMap tools, so I'm definitely at the forefront of the beginners stage lol. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:24:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-the-map-to-kml-tool/m-p/89156#M6920</guid>
      <dc:creator>CoyPotts1</dc:creator>
      <dc:date>2021-12-10T23:24:30Z</dc:date>
    </item>
  </channel>
</rss>

