<?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: Export layer packages from outside ArcMap using python. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/export-layer-packages-from-outside-arcmap-using/m-p/112537#M8771</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Chris,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; everything is working well right now! &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank's a lot! Very usefull help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Samuel&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Aug 2011 11:39:04 GMT</pubDate>
    <dc:creator>SamuelBoisvert</dc:creator>
    <dc:date>2011-08-03T11:39:04Z</dc:date>
    <item>
      <title>Export layer packages from outside ArcMap using python.</title>
      <link>https://community.esri.com/t5/python-questions/export-layer-packages-from-outside-arcmap-using/m-p/112533#M8767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I was wondering if there is a way to use a python script from outside ArcMap that export a series of layer packages to a given folder. I built the following script mainly with Model Builder inside the .mxd from which I want to export the packages, as a matter of fact that script works well when I start it inside my ArcMap document.... The problem is that I want it to run from outside ArcGIS. So I have to find a way to reference (inside my script) the mxd from which I want the layers package to be exported from. Does anyone have any solution on how I could do that?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hereâ??s my python script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# ---------------------------------------------------------------------------
# JavaScript.py
# Created on: 2011-07-13 08:38:45.00000
#&amp;nbsp;&amp;nbsp; (generated by ArcGIS/ModelBuilder)
# Description: To be added...
# Auteur: Samuel Boisvert
# ---------------------------------------------------------------------------
# Import arcpy module
import arcpy

# Set the workspace
arcpy.env.workspace = "c:/LPK"

# Overwrite pre-existing files
arcpy.env.overwriteOutput = True

# Local variables
Layer = "Layer"
Paquetage = "C:\\LPK\\LPK.lpk"

# Process: Package Layer
arcpy.PackageLayer_management("Layer", Paquetage, "PRESERVE", "CONVERT_ARCSDE", "DEFAULT", "ALL", "ALL", "CURRENT")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Samuel Boisvert&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:01:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-layer-packages-from-outside-arcmap-using/m-p/112533#M8767</guid>
      <dc:creator>SamuelBoisvert</dc:creator>
      <dc:date>2021-12-12T16:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: Export layer packages from outside ArcMap using python.</title>
      <link>https://community.esri.com/t5/python-questions/export-layer-packages-from-outside-arcmap-using/m-p/112534#M8768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Samuel,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You would want to something like the following to get a reference to the layer in the map document.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
mxd = arcpy.mapping.MapDocument(r"C:\Data\MyMapDoc.mxd")
lyr = arcpy.mapping.ListLayers(mxd, "LayerName")[0]
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:43:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-layer-packages-from-outside-arcmap-using/m-p/112534#M8768</guid>
      <dc:creator>ChrisFox3</dc:creator>
      <dc:date>2021-12-11T06:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: Export layer packages from outside ArcMap using python.</title>
      <link>https://community.esri.com/t5/python-questions/export-layer-packages-from-outside-arcmap-using/m-p/112535#M8769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Chris!,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; thanks for the answer! As you suggested I did some changes in my code. As I run the code, the layer package failed to proceed (error 99999). I looked for common errors like "layer without a description" but everything is ok. I succeeded exporting manually the layer to a package so it's probably something missing in the script! Any idea?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's the python script i've been using:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Import arcpy module
import arcpy

# Set the workspace
arcpy.env.workspace = "c:/LPK"

# Overwrite pre-existing files
arcpy.env.overwriteOutput = True

# Local variables:
mxd = arcpy.mapping.MapDocument(r"C:\LPK\Paquetage_de_Couche.mxd")
lyr = arcpy.mapping.ListLayers(mxd, "Test")[0]
Package = r"C:\LPK\Packaged_Layer.lpk"

# Process: Package Layer
arcpy.PackageLayer_management(lyr, Package, "PRESERVE", "CONVERT_ARCSDE", "DEFAULT", "ALL", "ALL", "CURRENT")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thank's in advance!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Samuel Boisvert&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:01:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-layer-packages-from-outside-arcmap-using/m-p/112535#M8769</guid>
      <dc:creator>SamuelBoisvert</dc:creator>
      <dc:date>2021-12-12T16:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Export layer packages from outside ArcMap using python.</title>
      <link>https://community.esri.com/t5/python-questions/export-layer-packages-from-outside-arcmap-using/m-p/112536#M8770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Samuel,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry about that but forgot one additional step. It is not possible to just pass in a layer object as an input to the geoprocessing tool, first you need to convert it toa layer file and then pass in the layer file path. Below is a sample:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# Import arcpy module
import arcpy

# Set the workspace
arcpy.env.workspace = "c:/LPK"

# Overwrite pre-existing files
arcpy.env.overwriteOutput = True

# Local variables:
mxd = arcpy.mapping.MapDocument(r"C:\LPK\Paquetage_de_Couche.mxd")
lyr = arcpy.mapping.ListLayers(mxd, "Test")[0]
lyrFilePath = r"C:\LPK\myLayerFile.lyr"
lyr.saveACopy(r"C:\LPK\myLayerFile.lyr")
Package = r"C:\LPK\Packaged_Layer.lpk"

# Process: Package Layer
arcpy.PackageLayer_management(lyrFilePath, Package, "PRESERVE", "CONVERT_ARCSDE", "DEFAULT", "ALL", "ALL", "CUR

#Optionally delete layer file when done
arcpy.Delete_management(lyrFilePath)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:43:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-layer-packages-from-outside-arcmap-using/m-p/112536#M8770</guid>
      <dc:creator>ChrisFox3</dc:creator>
      <dc:date>2021-12-11T06:43:44Z</dc:date>
    </item>
    <item>
      <title>Re: Export layer packages from outside ArcMap using python.</title>
      <link>https://community.esri.com/t5/python-questions/export-layer-packages-from-outside-arcmap-using/m-p/112537#M8771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Chris,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; everything is working well right now! &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank's a lot! Very usefull help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Samuel&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2011 11:39:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-layer-packages-from-outside-arcmap-using/m-p/112537#M8771</guid>
      <dc:creator>SamuelBoisvert</dc:creator>
      <dc:date>2011-08-03T11:39:04Z</dc:date>
    </item>
  </channel>
</rss>

