Hot answers tagged

10

I found the answer right after I asked the question. The Table of Contents lists Draw Order for layouts. You can select any map element in this draw order and change the order they draw in the layout.


3

You are getting this error because the arcpy.mapping.MapDocument object does not support iteration. You would need to construct a list of map document files (which can be done with os.walk() or a list of arcpy.mapping.MapDocument objects and then iterate it. So the line for map in mxd: should be removed. import arcpy.mapping as mapping, os for root, dirs, ...


3

The cryptic "names" of each text element you see in the list, such as <TextElement object at 0x23ddb50[0x15325228]> is just a pointer to a memory address and not the actual name of the text element you give within a map document. To be able to list the names of a text element, you'd need to use its name property as below: [elem.name for elem in ...


3

I have tested the code on 10.3.1 and 10.5. You don't need to ungroup the graphic element in order to change the text of the group's items. In other words, you should be able to alter the properties (eg text) of a TEXT_ELEMENT even if it is grouped and is a part of a GRAPHIC_ELEMENT. The original image: >>> import arcpy.mapping as mp >>> ...


3

Your output suggests that your script found a layout element of type text element in each of three maps, and that it moved each of them. When working with layout elements I think you would be wise to give each of them a unique name on their Size & Position tab so that you can use their name property (e.g. elm.name) to access them. I'm not clear from ...


2

Yes, just do a search cursor to get the specific field/record value and update layout default title text (you set this within a template map document), see sample code below. import arcpy # run search cursor here mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd") for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"): if elm.text == "...


2

You don't need to wrap the element name in quotes like you are doing. You can use string formatting to do this slightly more cleanly: a1 = "element{0}".format(1) See also my suggestions on general Python tips in this answer.


1

All three properties you are working with are Read/Write properties, so to test what is happening and whether things are changing I would focus on just one MXD (and once it's working set it to loop through all your MXDs), and print the fontSize, elementPositionX, elementPositionY before and after each change, to see what it is doing and whether it is ...


1

This could be done using python script to call arcobject LayoutTools_Ungroup command using comtypes, see: Accessing ArcObjects from Python? and ArcMap Commands


1

If there were a way to do this from ArcPy then I would expect to see ungroup amongst the methods on the GraphicElement class. As you can see from its documentation there is not one. Consequently, you may want to consider looking for or submitting an ArcGIS Idea. There is no ungroup method for the GraphicElement class for ArcPy with ArcGIS Pro either.


1

First of all you can't just assign null to _SelectMyElement and then use it. It will cause an exception later. Second pGraphicsCont does not implement ITextElement. You should uncomment your assignment of _SelectMyElement and select _textElement. You also might need to refresh the display. if (item.Caption == Convert.ToString(_propertySet.GetProperty(...


1

Unfortunately, this is far from an instant solution, but there is an ArcGIS Idea to be able to Lock Graphic Features in ArcMap that it looks like you should vote for (I just did). If this is important to you I would advise creating an equivalent ArcGIS Idea to have this in ArcGIS Pro because I suspect it is more likely to come to fruition in that next ...


Only top voted, non community-wiki answers of a minimum length are eligible