Thursday, 15 November 2018

arcmap - Access resolved/rendered dynamic text from ArcPy or ArcObjects?



Using ArcPy (or ArcObjects if essential), is there a way to retrieve the rendered text of a text element that includes Dynamic Text?


The text property of the TextElement includes the Dynamic Text tags, but I would like to access the resolved text that will be displayed on the map.


For example for a title page at the moment:


myTextElement.text = "Country Map - Name: 
- Code: "

But I'd like to get the resolved dynamic text, in this example from a data driven page:


Country Map - Name: Zimbabwe - Code: ZW

This is to be able to export metadata for maps produced using data driven pages. At the moment without a method to access the resolved value of the dynamic text the only solutions we can think of are to either;




  1. Write a class to parse and resolve the dynamic text.


This wouldn't be too difficult to do as the datadriven page class includes a property to the index layer, but I expect running an attribute cursor for each page would slow exports down.



  1. Save the MXD for ArcMap 9.3 which doesn't support dynamic text (this strips the dynamic text from the layout and replaces it with it's values).


While this would work it seems a long way around, as after saving a copy the map document would then need to be opened to retrieve the text element value.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...