import MXD not working

512
5
02-04-2020 09:41 AM
SteveScott
New Contributor III

I cannot import an mxd. It saves as a blank document.

I have the following code: 

    #Open the blank project
    aprx_blank = arcpy.mp.ArcGISProject(aprx_path_blank)
    
    #create a copy of the blank project to the local drive
    aprx_path = temp_path / "aprx_temp.aprx"
    aprx_path_string = str(aprx_path)
    if os.path.exists(aprx_path_string):
        os.remove(aprx_path_string)
    aprx_blank.saveACopy(aprx_path_string)
    aprx_copy = arcpy.mp.ArcGISProject(aprx_path_string)

 
    #Import the mxd into the copy projet
    mxd_path_string = str(root / directory / (file_name + ".mxd"))
    aprx_copy.importDocument(mxd_path_string)
    aprx_copy.save()

mxd_path_string is a valid URI that points to the correct map.

When I open the aprx_temp.aprx file in ArcGIS Pro, the map is empty.

Why isn't save working?

0 Kudos
5 Replies
BenTurrell
Occasional Contributor III

Hey Steve Scott‌,

Are you getting any error messages when you run the script?

Thanks,

Ben


If this answer has helpful please mark it as helpful. If this answer solved your question please mark it as the answer to help others who have the same question.

SteveScott
New Contributor III

No I am not getting any error messages at this stage.

0 Kudos
SteveScott
New Contributor III

It is interesting, though. In my script it is behaving like it is being imported. I change the MXD and the result changes correctly later on when I publish. But when I check the aprx it is empty.

0 Kudos
JoshuaWatson1
New Contributor II

Hi Steve,

It sounds like the Mxd is loading into the aprx correctly; although the problem is typically that Maps do not 'Open' by default. 

Within the newly copied aprx, can you check the Catalog, and see if there is an additional Map within there. There should be one called the same thing as the Mxd Data Frame (by default this would be 'Layers').

This new map, should be the imported Mxd.

A good indication is just to quickly compare the sizes of the aprx files. The newly created one should be slightly larger.

Hope this helps but let me know if this isn't the issue,

Josh

SteveScott
New Contributor III

Okay, I see it in the catalog. It is interesting because the project is only 24kb so I assumed it didn't import. Must be in the geodatabase. Thanks!

0 Kudos