ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Core.CIM Namespace / CIMMaplexDictionary Class
Members Example

In This Topic
    CIMMaplexDictionary Class
    In This Topic
    Represents a Maplex dictionary.
    Object Model
    CIMMaplexDictionary ClassCIMMaplexDictionary ClassCIMMaplexDictionary Class
    Syntax
    Example
    Create and apply Abbreviation Dictionary in the Map Definition to a layer
    public static void CreateDictionary()
    {
      //Get the map's defintion
      var mapDefn = MapView.Active.Map.GetDefinition();
      //Get the Map's Maplex labelling engine properties
      var mapDefnPlacementProps = mapDefn.GeneralPlacementProperties as CIMMaplexGeneralPlacementProperties;
    
      //Define the abbreaviations we need in an array            
      List<CIMMaplexDictionaryEntry> abbreviationDictionary = new List<CIMMaplexDictionaryEntry>
            {
                new CIMMaplexDictionaryEntry {
                Abbreviation = "Hts",
                Text = "Heights",
                MaplexAbbreviationType = MaplexAbbreviationType.Ending
    
             },
                new CIMMaplexDictionaryEntry
                {
                    Abbreviation = "Ct",
                    Text = "Text",
                    MaplexAbbreviationType = MaplexAbbreviationType.Ending
    
                }
                //etc
            };
      //The Maplex Dictionary - can hold multiple Abbreviation collections
      var maplexDictionary = new List<CIMMaplexDictionary>
            {
                new CIMMaplexDictionary {
                    Name = "NameEndingsAbbreviations",
                    MaplexDictionary = abbreviationDictionary.ToArray()
                }
    
            };
      //Set the Maplex Label Engine Dictionary property to the Maplex Dictionary collection created above.
      mapDefnPlacementProps.Dictionaries = maplexDictionary.ToArray();
      //Set the Map defintion 
      MapView.Active.Map.SetDefinition(mapDefn);
    }
    
    private static void ApplyDictionary()
    {
      var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().First();
    
      QueuedTask.Run(() =>
      {
        //Creates Abbreviation dictionary and adds to Map Defintion                                
        CreateDictionary();
        //Get the layer's definition
        var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer;
        //Get the label classes - we need the first one
        var listLabelClasses = lyrDefn.LabelClasses.ToList();
        var theLabelClass = listLabelClasses.FirstOrDefault();
        //Modify label Placement props to use abbreviation dictionary 
        CIMGeneralPlacementProperties labelEngine = MapView.Active.Map.GetDefinition().GeneralPlacementProperties;
        theLabelClass.MaplexLabelPlacementProperties.DictionaryName = "NameEndingsAbbreviations";
        theLabelClass.MaplexLabelPlacementProperties.CanAbbreviateLabel = true;
        theLabelClass.MaplexLabelPlacementProperties.CanStackLabel = false;
        //Set the labelClasses back
        lyrDefn.LabelClasses = listLabelClasses.ToArray();
        //set the layer's definition
        featureLayer.SetDefinition(lyrDefn);
      });
    }
    
    
    Create and apply Abbreviation Dictionary in the Map Definition to a layer
    public static void CreateDictionary()
    {
      //Get the map's defintion
      var mapDefn = MapView.Active.Map.GetDefinition();
      //Get the Map's Maplex labelling engine properties
      var mapDefnPlacementProps = mapDefn.GeneralPlacementProperties as CIMMaplexGeneralPlacementProperties;
    
      //Define the abbreaviations we need in an array            
      List<CIMMaplexDictionaryEntry> abbreviationDictionary = new List<CIMMaplexDictionaryEntry>
            {
                new CIMMaplexDictionaryEntry {
                Abbreviation = "Hts",
                Text = "Heights",
                MaplexAbbreviationType = MaplexAbbreviationType.Ending
    
             },
                new CIMMaplexDictionaryEntry
                {
                    Abbreviation = "Ct",
                    Text = "Text",
                    MaplexAbbreviationType = MaplexAbbreviationType.Ending
    
                }
                //etc
            };
      //The Maplex Dictionary - can hold multiple Abbreviation collections
      var maplexDictionary = new List<CIMMaplexDictionary>
            {
                new CIMMaplexDictionary {
                    Name = "NameEndingsAbbreviations",
                    MaplexDictionary = abbreviationDictionary.ToArray()
                }
    
            };
      //Set the Maplex Label Engine Dictionary property to the Maplex Dictionary collection created above.
      mapDefnPlacementProps.Dictionaries = maplexDictionary.ToArray();
      //Set the Map defintion 
      MapView.Active.Map.SetDefinition(mapDefn);
    }
    
    private static void ApplyDictionary()
    {
      var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().First();
    
      QueuedTask.Run(() =>
      {
        //Creates Abbreviation dictionary and adds to Map Defintion                                
        CreateDictionary();
        //Get the layer's definition
        var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer;
        //Get the label classes - we need the first one
        var listLabelClasses = lyrDefn.LabelClasses.ToList();
        var theLabelClass = listLabelClasses.FirstOrDefault();
        //Modify label Placement props to use abbreviation dictionary 
        CIMGeneralPlacementProperties labelEngine = MapView.Active.Map.GetDefinition().GeneralPlacementProperties;
        theLabelClass.MaplexLabelPlacementProperties.DictionaryName = "NameEndingsAbbreviations";
        theLabelClass.MaplexLabelPlacementProperties.CanAbbreviateLabel = true;
        theLabelClass.MaplexLabelPlacementProperties.CanStackLabel = false;
        //Set the labelClasses back
        lyrDefn.LabelClasses = listLabelClasses.ToArray();
        //set the layer's definition
        featureLayer.SetDefinition(lyrDefn);
      });
    }
    
    
    Inheritance Hierarchy

    System.Object
       ArcGIS.Core.CIM.CIMObject
          ArcGIS.Core.CIM.CIMMaplexDictionary

    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also