In our Office we use pre-defined, read-only .mxd Projects. For saving edited projects I made a little python Add-in which allows the user to save the mxd in a subfolder of a Default-path, which is selected by the user with the pythonaddins.SaveDialog. My Problem is, that I can't implement the "Save as" Operation without re-start the Project. Because it's not possible to use the mxd.save function with variables. For better understanding here my code:
class Save As(object): """Implementation for Python_Addins_addin.btn_save (Button)""" def __init__(self): self.enabled = True self.checked = False def onClick(self): infile = pythonaddins.SaveDialog("Save As", "Protected_Areas.mxd",r"\\VWMSERV2\Geodaten_Export","Mxd Files (*.mxd)") #User selects his subpath in the Geodaten_Export Folder savepath = os.path.normpath(infile) save_folder = os.path.dirname(savepath) mxd_save = os.path.join(save_folder+"\Protected_Areas") mxd_open = os.path.join(mxd_save + ".mxd") mxd.saveACopy(mxd_save) # mxd.save only accepts "current" or static path names os.system("taskkill/IM Arcmap*") #close time.sleep(10) #break of 10 sec. Otherwise ArcMap crashes. Even if the break is to short. os.startfile(mxd_open)Has anybody experiences with this?
أكثر...
class Save As(object): """Implementation for Python_Addins_addin.btn_save (Button)""" def __init__(self): self.enabled = True self.checked = False def onClick(self): infile = pythonaddins.SaveDialog("Save As", "Protected_Areas.mxd",r"\\VWMSERV2\Geodaten_Export","Mxd Files (*.mxd)") #User selects his subpath in the Geodaten_Export Folder savepath = os.path.normpath(infile) save_folder = os.path.dirname(savepath) mxd_save = os.path.join(save_folder+"\Protected_Areas") mxd_open = os.path.join(mxd_save + ".mxd") mxd.saveACopy(mxd_save) # mxd.save only accepts "current" or static path names os.system("taskkill/IM Arcmap*") #close time.sleep(10) #break of 10 sec. Otherwise ArcMap crashes. Even if the break is to short. os.startfile(mxd_open)Has anybody experiences with this?
أكثر...