Add graphic element with ArcPy

2265
5
10-19-2010 01:43 AM
Status: Implemented
Labels (1)
XanderBakker
Esri Esteemed Contributor

It would be nice to be able to use the Mapping module of ArcPy to add new elements to a layout. At this moment the suggested procedure is to pre-author the element and position it outside the layout. Using ArcObjects it is simple to create new elements, but since VBA is being phased-out and the alternative is creating a python script, these simple tasks should be possible without the need to create an Add-In.

5 Comments
DanielaBramante

It would be useful to add an "InsertLayoutElement" function to arcpy.mapping. Given each of the element properties, it should be an easy addition.

This would allow for the insertion of all element objects outlined in "ListLayoutElements".

DavidMahoney

Even better, maintain the list of graphic elements in a structure compatible with a python list. The list ordering could determin z-order of the elements. I would love to be able to do something like:

>>> text = TextElement()
>>> text.Text = "Map Title"
>>> mxd  = MapDocument("CURRENT")
>>> mxd.LayoutElements.insert(0,text)
>>> mxd.LayoutElements
[<TextElement object at 0x293b0850[0x293b0160]>, <DataFrame object at 0x293b07d0[0x28cc8890]>]


While we're at it, make the mapping API a little more object-oriented, putting the layout elements in as a property of the map object.
 
JeffBarrette
Status changed to: Under Consideration

This is something we definitely want to address but it will take time.  Arcpy.mp has definitely grown beyond the capabilities of arcpy.mapping (for ArcMap).  At 3.1 we are adding some content management operations like ArcGISProject.createMap(), ArcGISProject.deleteItem() /  ArcGISProject.copyItem() - for maps, layouts, and reports, and ArcGISProject.updateFolderConnections().

We didn't add createLayout because there is no point in creating a layout when we also can't create all the possible layout elements.  It will come in time.  At least with Pro 3.1 you'll be able to copy and existing layout and make modifications.  Currently, you can also export a layout to PAGX and import it to essentially make a copy.

Jeff - Layout and arcpy.mp teams

JeffBarrette
Status changed to: In Product Plan

This will be available at Pro 3.2.  You will have the ability to create new Layouts and layout elements including graphic elements.  The functions will be ArcGISProject.createGraphicElement() and ArcGISProject.createPredefinedGraphicElement(). They on the ArcGISProject object because you can create graphic elements on a layout OR in a map's graphics layer.

In addition to the constructors, we also will expose a get/SetDefinition on layout elements.  This makes it much easier to get to many more properties including symbology.  Post 3.2 we hope to add additional symbology constructors that make setting symbology more streamlined w/o having to use the CIM.

 

Jeff - Layout and arcpy.mp teams

JeffBarrette
Status changed to: Implemented

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

The Your Ideas in ArcGIS Pro 3.2 blog and video have been posted to the Esri Community blog. You can take a look at these to see your idea and all others that were implemented in this release of ArcGIS Pro.

Jeff - Layout and arcpy.mp teams