I am trying to import multiple MXDs into an existing ArcGIS Pro project using arcpy.
When I run the code it completes successfully but when I open the ArcGIS Pro project there is nothing there. I changed the Pro Project variable to 'CURRENT' and inserted the code in ArcGIS Pro's Python terminal and it works fine. Just confused on why the script would run in ArcGIS Pro and not outside.
# Specify the mxd directory
mxdDir = r'C:\Users\rossch\Downloads\NS114_BasemapMXDs'
proProj = 'C:\Users\rossch\Downloads\ArcGISPro_MXDImport\ArcGISPro_MXDImport.aprx'
# Set workspace
arcpy.env.workspace = mxdDir
# List the mxds
mxds = arcpy.ListFiles('*.mxd')
aprx = arcpy.mp.ArcGISProject(proProj)
for mxd in mxds:
mxdFilePath = os.path.join(mxdDir, mxd)
aprx.importDocument(mxdFilePath)
This was the code I used outside ArcGIS Pro.