ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / StyleHelper Class / LookupItem Method
The StyleProjectItem to search.
StyleItemType
The Key of the StyleItem that is to be retrieved.
Example

In This Topic
    LookupItem Method
    In This Topic
    Retrieves a specific style item from a style. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Shared Function LookupItem( _
       ByVal styleProjectItem As StyleProjectItem, _
       ByVal type As StyleItemType, _
       ByVal key As String _
    ) As StyleItem

    Parameters

    styleProjectItem
    The StyleProjectItem to search.
    type
    StyleItemType
    key
    The Key of the StyleItem that is to be retrieved.

    Return Value

    Exceptions
    ExceptionDescription
    This method must be called within the lambda passed to QueuedTask.Run
    Example
    How to search for a specific item in a style
    public Task<SymbolStyleItem> GetSymbolFromStyleAsync(StyleProjectItem style, string key)
    {
      return QueuedTask.Run(() =>
      {
        if (style == null)
            throw new System.ArgumentNullException();
    
        //Search for a specific point symbol in style
        SymbolStyleItem item = (SymbolStyleItem)style.LookupItem(StyleItemType.PointSymbol, key);
        return item;
      });
    }
    Create and Set a ClassBreaks Renderer
    //Must be called on the MCT
    //var pcsl = ...;
    
    //At 2.x - var fields = pcsl.QueryAvailablePointCloudRendererFields(
    //                          PointCloudRendererType.ClassBreaksRenderer);
    
    var fields = pcsl.GetAvailablePointCloudRendererFields(
                         PointCloudRendererType.ClassBreaksRenderer);
    var classBreakDef = new PointCloudRendererDefinition(
                              PointCloudRendererType.ClassBreaksRenderer)
    {
      //ELEVATION or INTENSITY
      Field = fields[0]
    };
    //create the renderer
    var cbr = pcsl.CreateRenderer(classBreakDef) 
                              as CIMPointCloudClassBreaksRenderer;
    //Set up a color scheme to use
    var style = Project.Current.GetItems<StyleProjectItem>()
                               .First(s => s.Name == "ArcGIS Colors");
    var rampStyle = style.LookupItem(
      StyleItemType.ColorRamp, "Spectrum By Wavelength-Full Bright_Multi-hue_2")
                                                                as ColorRampStyleItem;
    var colorScheme = rampStyle.ColorRamp;
    //Set up 6 manual class breaks
    var breaks = 6;
    var colors = ColorFactory.Instance.GenerateColorsFromColorRamp(
                                                colorScheme, breaks);
    var classBreaks = new List<CIMColorClassBreak>();
    var min = cbr.Breaks[0].UpperBound;
    var max = cbr.Breaks[cbr.Breaks.Count() - 1].UpperBound;
    var step = (max - min) / (double)breaks;
    
    //add in the class breaks
    double upper = min;
    for (int b = 1; b <= breaks; b++)
    {
      double lower = upper;
      upper = b == breaks ? max : min + (b * step);
      var cb = new CIMColorClassBreak()
      {
        UpperBound = upper,
        Label = string.Format("{0:#0.0#} - {1:#0.0#}", lower, upper),
        Color = colors[b - 1]
      };
      classBreaks.Add(cb);
    }
    cbr.Breaks = classBreaks.ToArray();
    pcsl.SetRenderer(cbr);
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also