Select to view content in your preferred language

Text does not obey anchor point when contents changed

5255
5
Jump to solution
05-05-2015 08:25 AM
BrandonNelson1
New Contributor III

I'm trying to position a text element in the bottom-left corner of my map, but having a problem that seems similar to these.

     Print Service not honoring Anchor Points​​

     Data Driven Page Name Location Issues

     Dynamic Text in Data Driven Pages won't stay put

Specifically, I want to replace the text using ArcPy; however, despite that I made sure the text element is anchored at the bottom-left, when I change the contents, it behaves as if the anchor is in the top-left, and text sprawls off the bottom of the page:

textelem.png

Is this expected behavior?  What am I missing? Do text elements simply not respect (at least the vertical aspect of) the anchor point; does it anchor only the first line; does the anchor not update when text is changed?

I can probably position it myself in the script, but I'd like to know if there's a better way.

0 Kudos
1 Solution

Accepted Solutions
DavidBarnes
Occasional Contributor III

I can think of 2 possible courses of action.

1. Use rectangle text and make it big enough to fit the most text you're likely to have, and anchor it where you want.

2. Use the point text, and reset the anchor point position as part of your ArcPy script. I don't know enough about ArcPy to know how to do that, or how easy or complex it might be, but I'm sure someone here could offer suggestions.

View solution in original post

5 Replies
DavidBarnes
Occasional Contributor III

Not sure if this will help, but here are some thoughts:

Are you using polygon text or point text?

You might try setting the text alignment properties; go into the text properties where you can set both vertical and horizontal alignment.

BrandonNelson1
New Contributor III

Yes, it's regular/point text; I had forgotten about the vertical alignment setting, thanks. (Arc seems to have quite a few "well-hidden" features....)  After setting that, I can change the text manually in ArcMap and it aligns correctly, but unfortunately it still comes out wrong when changed in ArcPy.

0 Kudos
DavidBarnes
Occasional Contributor III

I can think of 2 possible courses of action.

1. Use rectangle text and make it big enough to fit the most text you're likely to have, and anchor it where you want.

2. Use the point text, and reset the anchor point position as part of your ArcPy script. I don't know enough about ArcPy to know how to do that, or how easy or complex it might be, but I'm sure someone here could offer suggestions.

BrandonNelson1
New Contributor III

In fact I was looking into #2 when I got your response, and that did it.  I save the element position, change the text, then restore the original position:

AddrList = arcpy.mapping.ListLayoutElements(Document, "TEXT_ELEMENT", "AddrList")[0]
position = AddrList.elementPositionX, AddrList.elementPositionY
AddrList.text = "New\ntext\nwith\nmultiple\nlines"
AddrList.elementPositionX, AddrList.elementPositionY = position

I also tried #1 out of curiosity (it didn't pan out :/).

0 Kudos
DavidBarnes
Occasional Contributor III

Ah, good to hear you found some solution!

0 Kudos