arcgis python 一个mxd打包mpk
def onempk(fileName): if fileName: mxd = arcpy.mapping.MapDocument(fileName) else: mxd = arcpy.mapping.MapDocument("current") fileName=mxd.filePath filepath, filename = os.path.split(fileName) b=False if mxd.title==None: mxd.title="yl create"+filename b=True if mxd.description==None: mxd.description="yl auto create"+filename b=True elif mxd.description=="": mxd.description="yl auto create"+filename b=True if mxd.author==None: mxd.author="yanlei auto create" b=True if mxd.summary==None: mxd.summary="yanlei auto create summary" b=True if mxd.relativePaths==False: mxd.relativePaths=True b=True if b==True: mxd.save() arcpy.env.workspace = filepath mpk=filename.lower().replace(".mxd",".mpk") #arcpy.AddMessage("mpk:"+mpk+","+mpk[0:1]) if (is_number(mpk[0:1])): mpk="YL_"+mpk #邮件附件不能数字开头 arcpy.PackageMap_management(filename, mpk, "PRESERVE", "#", "#", "ALL") return filepath+os.sep+mpk