Select to view content in your preferred language

Conversion of MXDs to APRX Using Python

1545
11
01-07-2024 09:30 PM
naveenbesri
Frequent Contributor

Hi All,

I have been using python script for conversion of MXDs to APRX files. we are able to create the aprx files but when I open its empty no layers or properties in newly converted aprx file. below is the script

 

import os
import pathlib
import arcpy

ogDir = r'D:\MXDs'
dirContents = os.listdir(ogDir)

for folder_path, subfolders, filenames in os.walk(ogDir):
for file in filenames:
if file[-4:] == '.mxd':
aprx = arcpy.mp.ArcGISProject('Current')
filePath = pathlib.Path(folder_path) / file
mxd = file[:-4]
aprx.importDocument(filePath)
aprx.saveACopy(folder_path + '\\' + mxd + '.aprx')

 

Kindly help me out where I can get same as like my MXD into aprx file. 

 

Thanks,

Naveen

0 Kudos
11 Replies
mody_buchbinder
Frequent Contributor

Hi all

 

The first question is what happen if you just use Pro to import the MXD - no Python.

If it gives you the data then it is a python problem.

If it gives you empty map then python have nothing to do here.

0 Kudos
naveenbesri
Frequent Contributor

HI @mody_buchbinder I tried to import the MXD everything looks fine. I am able to see the data and layers in TOC. 

0 Kudos