Arcpy Delete Multiple Elements

1045
2
03-07-2017 04:26 AM
Yusuf_CelilKonak
New Contributor III

From documentation (GraphicElement—Help | ArcGIS for Desktop ) elements can be deleted as below but after one element deletion layout refreshes with delete function and if you have good amount of elements at layout this operation requires good time to be finished. How can this elements can be deleted simultaneously ? One delete and refresh operation would be better for time perpective, any idea'd be helpful.

for elm in arcpy.mapping.ListLayoutElements(mxd, wildcard="_clone"😞

   elm.delete() del mxd

Thanks in advance.

0 Kudos
2 Replies
IanMurray
Frequent Contributor

Hi Yusuf,

The only reason the layout view would need to refresh after each deletion is if you were running this code with the python interpreter in an actual map document.  Why not run a standalone script that opens the map document in memory and deletes the cloned graphic elements.  The only time the layout view changes when processing outside of a map document is when you tell the layout to refresh the active view or save the map.

0 Kudos
Yusuf_CelilKonak
New Contributor III

Hi Ian,

That'll be at the end of project. For now, watching at mxd is better, faster. After executing stand-alone script, mxd opening was the avoided time cost  and now execution time on actual mxd starts to exceed that time.

Thanks. 

0 Kudos