ArcPy: Save and open mxd without closing ArcGIS

المشرف العام

Administrator
طاقم الإدارة
With Python Add-In Wizard I created a Button which:1) looks in a specific directory for the last created/modified folder (which is created with another tool)2) saves the current mxd with a new name in this folder3) starts the new project

What I want to fulfill is, that I don't need to open ArcGIS again for strating the new mxd and instead of this open the new mxd in the current ArcGIS session.Did anybody has experience with this and can help me?

Here my code:

import os, arcpyclass SaveNew(object):"""Implementation for Python_Addins_addin.btn_speichernneu (Button)""" def __init__(self): self.enabled = True self.checked = False def onClick(self): #searching for last created/modified folder in directory directory = r"\\VMSERV2\Geodata_Export" newfolder = max([os.path.join(directory,d) for d in os.listdir(directory)], key=os.path.getmtime) #set MapDocument and Saving and renaming in new folder mxd = arcpy.mapping.MapDocument("CURRENT") mxd.saveACopy(os.path.join(newfolder+"\NewProject")) # open new mxd -> here I want to open the “NewProject.mxd” in the current ArcGIS session os.startfile(os.path.join(newfolder," NewProject.mxd"))

أكثر...
 
أعلى