Populate Map Sheet Info (Defense Mapping)
Summary
Populates text in defense-specific graphic elements on an ArcMap layout. Text is populated with feature attribute values from a selected area of interest (AOI) feature in the map. The tool searches each graphic element for bracketed ([]) text. It compares bracketed text to values in a list. Any matching values are replaced in the graphic element with an attribute value from the selected AOI feature.
The PopMapInfo table, similar to a lookup table, maintains the relationship between feature attributes and bracketed text strings. The table contains the Field_Name and Element_Part fields which control the mapping between feature attributes and graphic elements. For example, the table maps the Sheet_Name attribute to the [SHEET NAME] text. Custom Field_Name and Element_Part attributes may be added to the table to allow for use of new feature attributes and associated graphic elements. The PopMapInfo table is located within the MapIndex database stored in <install path>\ESRIDefenseMapping\Desktop10.0\ReferenceData.
Usage
-
Input MXD must have a layout that contains graphic elements. This tool only updates bracketed text strings within those graphic elements. Bracketed text strings must follow the formats listed under element part (text) in the Feature attribute to graphic text mapping information document.
When running this tool against the active MXD, set the map display to layout view.
This tool updates all duplicate bracketed text strings. For example, a layout can have multiple [SHEET NAME] text strings.
Input Feature Layer represents an area of interest (AOI) feature. This parameter accepts only polygon features. Using other geometry types will return error 000366: Invalid geometry type.
Input Feature Layer must contain exactly one selected feature. This tool will return an error if the layer has 0 or more than 1 selected features.
Input Table defaults to the PopMapInfo table within the MapIndex database stored in <install path>\ESRIDefenseMapping\Desktop10.0\ReferenceData. Input Table contains the Field_Name and Element_Part fields which control the mapping between feature attributes and graphic elements.
Messages returned during tool execution include a list of replaced text.
Syntax
Parameter | Explanation | Data Type |
mxd |
The path to the .mxd to update. To update the active, currently loaded map document, use the CURRENT keyword. When using the active MXD, the tool must be run from the layout view. | File |
in_features |
A feature layer with a selection set containing one AOI feature. The tool writes attribute values from this feature to bracketed text strings in defense-specific graphic elements. | Feature Layer |
in_table |
An input table that contains the Field_Name and Element_Part fields. | Table |
Code Sample
The following Python window demonstrates how to execute the PopulateMapSheetInfo function using the CURRENT keyword.
# import the defense toolbox - you may have to change this path arcpy.ImportToolbox(r'C:\Program Files\ArcGIS\Desktop10.0\ArcToolbox\Toolboxes\Defense Mapping Tools.tbx') # select a feature - NOTE: the TLM50 feature layer must be present in the ArcMap TOC arcpy.SelectLayerByAttribute_management('TLM50',"NEW_SELECTION","Sheet_name='San Diego'") # get describe object from this feature layer desc = arcpy.Describe('TLM50') # check the FIDSet property (number of selected features) of the describe object numselected = len(desc.FIDSet) # path to the PopMapInfo table popMapInfoTbl = r'C:\Program Files\ArcGIS\EsriDefenseMapping\Desktop10.0\ReferenceData\MapIndex.mdb\PopMapInfo' # exec PopulateMapSheetInfo only if there's a single selected feature if numselected == 1: arcpy.PopulateMapSheetInfo_defense('CURRENT','TLM50',popMapInfoTbl) else: arcpy.AddError("PopulateMapSheetInfo requires 1 selected feature")
The following stand-alone script demonstrates how to execute the PopulateMapSheetInfo function using a path to a map document.
# Name: PopulateMapSheetInfo_standalone_Example.py # Description: Populates text in specific defense graphic elements in a layout. # Requires: Defense Mapping extension import arcpy # check out a defense license arcpy.CheckOutExtension('defense') try: # import the defense toolbox - you may have to change this path arcpy.ImportToolbox(r'C:\Program Files\ArcGIS\Desktop10.0\ArcToolbox\Toolboxes\Defense Mapping Tools.tbx') # make a feature layer for the in_features parameter # change this path to match your own data arcpy.MakeFeatureLayer_management(r'C:\DATA\defense.mdb\TLM50','TLM50') # select a feature arcpy.SelectLayerByAttribute_management('TLM50',"NEW_SELECTION","Sheet_name='San Diego'") # get describe object from this feature layer desc = arcpy.Describe('TLM50') # check the FIDSet property (number of selected features) of the describe object numselected = len(desc.FIDSet) # path to the PopMapInfo table popMapInfoTbl = r'C:\Program Files\ArcGIS\EsriDefenseMapping\Desktop10.0\ReferenceData\MapIndex.mdb\PopMapInfo' # exec PopulateMapSheetInfo only if there's a single selected feature if numselected == 1: # change the path to the mxd to match your data arcpy.PopulateMapSheetInfo_defense(r'C:\DATA\TLM50.mxd','TLM50') else: arcpy.AddError("PopulateMapSheetInfo requires 1 selected feature") # print all the messages from this script print arcpy.GetMessages() except Exception as e: print e.message # check in the extension arcpy.CheckInExtension('defense')