is it possible to delete a "PICTURE_ELEMENT" from a map document?
Have a map in 10.6 trying to delete a jpeg that's in the map.
Thanks#
Just encountered this same issue in ArcMap 10.7. An alternative to deleting the Picture Element would be to use the elementPositionX, elementPositionY attributes mentioned by @RandyBurton and set them to values that move the element off the layout page, e.g. set elementPositionX = -10.0, elementPositionY = -10.0. I'm sure the OP already implemented something similar rather than manually editing 400+ MXDs!
thanks, i had tried the '.delete' without much luck. your other suggestion may work. We're re-doing some mxds made by a contractor and need to remove their logo from the maps (can always do it manually, but there are over 400 mxds !)
Thanks again,
Pete
I've had some time to do some tests. While there is a delete() option for Text Elements, there is no such option for Picture Elements. However, you can make the image disappear if you set either the width or height to 0. Once it has been set to zero, it does not appear that you can bring the image back by adjusting the height/width. The name, elementPositionX, elementPositionY and imageSource parameters still contain their original values. So this does not appear to be a clean deletion. (If you are working inside ArcMap, you may need to refresh the view to see the changes.)
for elm in arcpy.mapping.ListLayoutElements(mxd, "PICTURE_ELEMENT"): elm.elementHeight = 0.0 # setting this to 0 will also set elementWidth to 0<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN></SPAN>
I've deleted text elements with arcpy, so it should be possible with something like (untested):
<SPAN class="keyword token">import</SPAN> arcpy mxd <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>MapDocument<SPAN class="punctuation token">(</SPAN>r<SPAN class="string token">"C:\Project\Project.mxd"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> elm <SPAN class="keyword token">in</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>ListLayoutElements<SPAN class="punctuation token">(</SPAN>mxd<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"PICTURE_ELEMENT"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> elm<SPAN class="punctuation token">.</SPAN>delete<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># delete all picture elements</SPAN> <SPAN class="comment token"># or if using name or sourceImage properties</SPAN> <SPAN class="comment token"># if elm.name == "Photo":</SPAN> <SPAN class="comment token"># if elm.sourceImage == r"C:\Project\Data\NewPhoto.bmp":</SPAN> <SPAN class="comment token"># elm.delete()</SPAN> mxd<SPAN class="punctuation token">.</SPAN>save<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">del</SPAN> mxd<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
See PictureElement for some information., but it doesn't really discuss .delete().
Hope this helps.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.