ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.CIM Namespace / CIMColorRamp Class
Members Example

In This Topic
    CIMColorRamp Class
    In This Topic
    Supports color ramp schemes in the CIM model by providing low level access to properties common amongst all color ramp types.
    Object Model
    CIMColorRamp ClassCIMColorSpace Class
    Syntax
    Remarks
    This is the base color ramp type which provides access to the color space.
    Example
    How to apply a color ramp from a style to a feature layer
    public async Task ApplyColorRampAsync(FeatureLayer featureLayer, List<string> fields)
    {
    
        StyleProjectItem style =
            Project.Current.GetItems<StyleProjectItem>()
                .FirstOrDefault(s => s.Name == "ColorBrewer Schemes (RGB)");
        if (style == null) return;
        var colorRampList = await QueuedTask.Run(() => 
                    style.SearchColorRamps("Red-Gray (10 Classes)"));
        if (colorRampList == null || colorRampList.Count == 0) return;
        CIMColorRamp cimColorRamp = null;
        CIMRenderer renderer = null;
        await QueuedTask.Run(() =>
        {
            cimColorRamp = colorRampList[0].ColorRamp;
            var rendererDef = new UniqueValueRendererDefinition(fields, null, cimColorRamp);
            renderer = featureLayer?.CreateRenderer(rendererDef);
            featureLayer?.SetRenderer(renderer);
        });
    
    }
    Create and Set a Stretch Renderer
    //Must be called on the MCT
    //var pcsl = ...;
    
    //At 2.x - var fields = pcsl.QueryAvailablePointCloudRendererFields(
    //                           PointCloudRendererType.StretchRenderer);
    
    var fields = pcsl.GetAvailablePointCloudRendererFields(
                             PointCloudRendererType.StretchRenderer);
    var stretchDef = new PointCloudRendererDefinition(
                              PointCloudRendererType.StretchRenderer)
    {
      //Will be either ELEVATION or INTENSITY
      Field = fields[0]
    };
    //Create the CIM Renderer
    var stretchRenderer = pcsl.CreateRenderer(stretchDef) 
                                       as CIMPointCloudStretchRenderer;
    //Apply a color ramp
    var style = Project.Current.GetItems<StyleProjectItem>()
                                    .First(s => s.Name == "ArcGIS Colors");
    var colorRamp = style.SearchColorRamps("").First();
    stretchRenderer.ColorRamp = colorRamp.ColorRamp;
    //Apply modulation
    stretchRenderer.ColorModulation = new CIMColorModulationInfo()
    {
      MinValue = 0,
      MaxValue = 100
    };
    //apply the renderer
    pcsl.SetRenderer(stretchRenderer);
    
    Inheritance Hierarchy
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also