Return Object for importDocument ()

03-15-2022 10:20 AM
Status: Implemented
Labels (1)
Occasional Contributor II

With Arcpy.MP you are able to bring in .mapx and .pagx into your project using the importDocument() function. Once you run the function, the map and or layout is added to your project but the only way to access those again in your script is to do listLayouts() or listMaps() and find it using its name.

It would be incredibly useful if after running importDocument() it would return the maps and layouts that were brought into the project. The function currently returns nothing, but if it could return a layout or map object or even a list, then it would be easier to work with it later in the script. I'm not always going to know the exact name of the map or layout that gets imported into my project.

Status changed to: Under Consideration

This is certainly worth considering.  It would have to be a list because there can be many Maps (data frames) and always one Layout.  The only catch-22 is with the names of the objects in the list.  For example, if the Layout name already existing in the project you are importing into, the new layout would have a sequential number appended to name because two layout project items can't have the same name.  Would you expect the list to have the original names or the new names, if a conflict exists?

Jeff - and Layout teams


Hey @JeffBarrette ,


Thanks for taking a look at this. A list would be fantastic either as just names or even better as layout/map objects. The example you point out is the exact issue I was encountering with my projects, because I wouldn't know the exact sequential number that would be assigned to the most recent imported map/layout. If importdocument() is returning a list of names, I would definitely expect it to give me the new name as that is how it is referenced in the project and listlayouts()/listmaps().

Status changed to: In Product Plan

This has been added to Pro 3.1

Import MXD (include_layout=True) returns the Layout object

ImportMXD (include_layout=False) returns first Map

Import3DD, SDX returns Map

ImportPAGX - Layout, ImportRPTX - Report, ImportMAPX - Map


Jeff - Layout and teams



That's great to hear! I look forward to trying it out in my next holistic session.

Status changed to: Implemented

This Idea has been implemented in ArcGIS Pro 3.1. Please see the What's New documentation for more new features in Pro 3.1.

The Ideas in ArcGIS Pro 3.1 blog will be wrapped up soon, highlighting all Ideas implemented in this release, including this one. Once complete, I will add the link to this comment.