Development Steps:
1. Tool: Read database connections
a. Reads all MXDs
b. Each layer’s database connection
c. Remove duplicates for connection info: per feature class
d. Load into spreadsheet
2. Manual: Repath database connections
a. Open spreadsheet
b. Change paths of data to UN data
i. Need to figure out AssetGroup and how that effects data connection string
c. Save spreadsheet
3. Tool: Convert MXDs
a. Reads database connection spreadsheet into dictionary
b. Configuration: Need a list of each FROM layer, path TO layer
c. Converts each MXD to APRX file
d. Repaths each layer to new UN
e. Saves APRX files
# File Name: ConvertMXDs_StandAloneScript.py
# Author: Lucas Broyles
# Company: SSP Innovations
# Date Created: 2/4/2019
# Date Modified: 2/5/2019
# Python Version: 3.6.9
# Script requirements:
# 1) arcpy python module
# 2) all input MXDs within a single folder
# 3) blank APRX file (no maps, print templates, etc)
# 4) write access to output conversion folder
# Comments:
# – Script will not repath or fix data sources
# – Script will convert mxds to Maps
# – Script will convert print templates to Layouts
# – When opening APRX files, navigate in Catalog to Maps and/or Templates to see conversion result
# Begin Code
import arcpy, os
from shutil import copyfile
print(“Begin MXD Conversion Script”)
#—– Input Parameters —–
# Script needs a blank APRX file. Use the Pro version you intend on creating all projects
blankAPRX = r”C:\\Users\\lbroyles\\Documents\\SSP – Clients\\Southern_Company\\MPC Specific\\_Received\\blank\\p20\\blank.aprx”
# Output folder to save all the converted Pro Projects
conversionFolder = r”C:\\Users\\lbroyles\\Documents\\SSP – Clients\\Southern_Company\\MPC Specific\\_Received\\UN MXD Examples\\Convert\\”
# Input folder that hosts all the MXD files to be converted
mxdFolder = r”C:\\Users\\lbroyles\\Documents\\SSP – Clients\\Southern_Company\\MPC Specific\\_Received\\UN MXD Examples\\”
#—– ArcPy Functions —–
# Loads all MXDs in mxdFolder to listFiles
arcpy.env.overwriteOutput = True
arcpy.env.workspace = mxdFolder
listFiles = arcpy.ListFiles(“*.mxd”)
num = 0
#—– Loop through MXD Files and convert to Pro Projects —–
for files in listFiles:
try:
print(“Converting input MXD: ” + files)
# copies blank APRX file each time to create one converted APRX for each input MXD
filename = (conversionFolder + str(os.path.splitext(files)[0] + “.aprx”))
inputAPRX2 = copyfile(blankAPRX, filename)
aprx = arcpy.mp.ArcGISProject(inputAPRX2)
inputMXD = os.path.join(mxdFolder, files)
aprx.importDocument(inputMXD)
aprx.save()
num = num + 1
except:
print(“Conversion Error for filename: ” + files)
pass
print(“”)
print(str(num) + ” total MXD files were converted to: ” + conversionFolder)
print(“Finished Script”)