Export layer packages from outside ArcMap using python.

Discussion created by geo_sam on Jul 22, 2011
Latest reply on Aug 3, 2011 by geo_sam
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?
Hereâ??s my python script:

# ---------------------------------------------------------------------------
# Created on: 2011-07-13 08:38:45.00000
#   (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")

Thank you
Best regards,

Samuel Boisvert