Chris Fox at Esri just kindly posted this example of using python to generate dynamic text outside of the data driven pages/index layer model:Below is a sample, this assumes i have a map document, two text elements in the layout, a layer named TestLayer with 2 fields "AddressField" and "ZipField".import arcpy# get the reference to the map document and the layer named "TestLayer" in the map documentmxd = arcpy.mapping.MapDocument("C:/Temp/Test.mxd")mapLyr = arcpy.mapping.ListLayers(mxd, "TestLayer")[0]# get the reference to the text elements in the map document. I have 2 text elements with the name Address and ZipaddrElem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "Address")[0]zipElem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "Zip")[0]# create a cursor and grab the first row in the feature class for the layer specified aboverows = arcpy.SearchCursor(mapLyr.dataSource)row = rows.next()# set the text property of the text element equal to the value from the fields named "AddressField" and "ZipField"addrElem.text = row.getValue("AddressField") zipElem.text = row.getValue("ZipField")# save the map document and delete the reference to the row, cursor and map objectmxd.save()del mxd, row, rows,
Is there a way to use python in a dynamic text where it looks for the dynamic text by attribute and depending on that value, you place and if else. If attribute = 0 then "No", else "Yes"?
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.