ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / Layer Class / GetDefinition Method
Example

In This Topic
    GetDefinition Method (Layer)
    In This Topic
    Returns the layer's CIM definition. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Overridable Function GetDefinition() As CIMBaseLayer
    public virtual CIMBaseLayer GetDefinition()

    Return Value

    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Hide or show editing tools on templates
    await QueuedTask.Run(() =>
       {
         //hide all tools except line tool on a given feature layer
         var editTemplates = featureLayer.GetTemplates();
         var newCIMEditingTemplates = new List<CIMEditingTemplate>();
    
         foreach (var et in editTemplates)
         {
           //initialize template by activating default tool
           et.ActivateDefaultToolAsync();
           var cimEditTemplate = et.GetDefinition();
           //get the visible tools on this template
           var allTools = et.ToolIDs.ToList();
           //add the hidden tools on this template
           allTools.AddRange(cimEditTemplate.GetExcludedToolIDs().ToList());
           //hide all the tools then allow the line tool
    
           allTools.AddRange(cimEditTemplate.GetExcludedToolIDs().ToList());
    
           cimEditTemplate.SetExcludedToolIDs(allTools.ToArray());
           cimEditTemplate.AllowToolID("esri_editing_SketchLineTool");
           newCIMEditingTemplates.Add(cimEditTemplate);
         }
         //update the layer templates
         var layerDef = featureLayer.GetDefinition() as CIMFeatureLayer;
         // Set AutoGenerateFeatureTemplates to false for template changes to stick
         layerDef.AutoGenerateFeatureTemplates = false;
         layerDef.FeatureTemplates = newCIMEditingTemplates.ToArray();
         featureLayer.SetDefinition(layerDef);
       });
    Access the display field for a layer
    {
        // get the CIM definition from the layer
        // Note: needs to be called on the MCT
        var cimFeatureDefinition = featureLayer.GetDefinition() as ArcGIS.Core.CIM.CIMBasicFeatureLayer;
        // get the view of the source table underlying the layer
        var cimDisplayTable = cimFeatureDefinition.FeatureTable;
        // this field is used as the 'label' to represent the row
        var displayField = cimDisplayTable.DisplayField;
    }
    Edit Color Modulation
    {
      // Note: call within QueuedTask.Run()
      {
        var def = pointCloudSceneLayer.GetDefinition() as CIMPointCloudLayer;
        //Get the ColorModulation off the renderer
        var modulation = def.Renderer.ColorModulation;
        if (modulation == null)
          modulation = new CIMColorModulationInfo();
        //Set the minimum and maximum intensity as needed
        modulation.MinValue = 0;
        modulation.MaxValue = 100.0;
        //apply back
        def.Renderer.ColorModulation = modulation;
        //Commit changes back to the CIM
        pointCloudSceneLayer.SetDefinition(def);
      }
    }
    Edit The Renderer to use Fixed Size
    {
      // Note: call within QueuedTask.Run()
      {
        var def = pointCloudSceneLayer.GetDefinition() as CIMPointCloudLayer;
    
        //Set the point shape and sizing on the renderer
        def.Renderer.PointShape = PointCloudShapeType.DiskShaded;
        var pointSize = new CIMPointCloudFixedSizeAlgorithm()
        {
          UseRealWorldSymbolSizes = false,
          Size = 8
        };
        def.Renderer.PointSizeAlgorithm = pointSize;
        //Commit changes back to the CIM
        pointCloudSceneLayer.SetDefinition(def);
      }
    }
    Edit the Renderer to Scale Size
    {
      // Note: call within QueuedTask.Run()
      {
        var def = pointCloudSceneLayer.GetDefinition() as CIMPointCloudLayer;
    
        //Set the point shape and sizing on the renderer
        def.Renderer.PointShape = PointCloudShapeType.DiskFlat;//default
        var scaleSize = new CIMPointCloudSplatAlgorithm()
        {
          MinSize = 8,
          ScaleFactor = 1.0 //100%
        };
        def.Renderer.PointSizeAlgorithm = scaleSize;
        //Commit changes back to the CIM
        pointCloudSceneLayer.SetDefinition(def);
      }
    }
    Edit Density settings
    {
      // Note: call within QueuedTask.Run()
      {
        var def = pointCloudSceneLayer.GetDefinition() as CIMPointCloudLayer;
        //PointsBudget - corresponds to Display Limit on the UI
        // - the absolute maximum # of points to display
        def.PointsBudget = 1000000;
    
        //PointsPerInch - corresponds to Density Min --- Max on the UI
        // - the max number of points per display inch to renderer
        def.PointsPerInch = 15;
        //Commit changes back to the CIM
        pointCloudSceneLayer.SetDefinition(def);
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also