ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / SymbolExtensionMethods Class / MakeSymbolReference Method
ArcGIS.Core.CIM.CIMSymbol
Example

In This Topic
    MakeSymbolReference Method
    In This Topic
    Makes symbol reference for a symbol.
    Syntax
    Public Shared Function MakeSymbolReference( _
       ByVal symbol As CIMSymbol _
    ) As CIMSymbolReference
    public static CIMSymbolReference MakeSymbolReference( 
       CIMSymbol symbol
    )

    Parameters

    symbol
    ArcGIS.Core.CIM.CIMSymbol

    Return Value

    Example
    How to get symbol reference from a symbol
    {
        CIMPolygonSymbol polySymbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB);
    
        //Get symbol reference from the symbol
        CIMSymbolReference symbolReference = polySymbol.MakeSymbolReference();
    }
    How to apply a symbol from style to a feature layer
    {
        //Note: Needs QueuedTask to run
        //Get simple renderer from the feature layer
        CIMSimpleRenderer currentRenderer = featureLayer.GetRenderer() as CIMSimpleRenderer;
        if (currentRenderer == null)
            return;
        //Get symbol from the SymbolStyleItem
        CIMSymbol symbolToApply = symbolStyleItem.Symbol;
    
        //Set symbol's real world setting to be the same as that of the feature layer
        symbolToApply.SetRealWorldUnits(featureLayer.UsesRealWorldSymbolSizes);
    
        //Update the symbol of the current simple renderer
        currentRenderer.Symbol = symbolToApply.MakeSymbolReference();
        //Update the feature layer renderer
        featureLayer.SetRenderer(currentRenderer);
    }
    How to apply a point symbol from a style to a feature layer
    {
          //Get the ArcGIS 2D System style from the Project
          var arcGIS2DStyle =
    Project.Current.GetItems<StyleProjectItem>().FirstOrDefault(s => s.Name == "ArcGIS 2D");
    
          //Note: Needs QueuedTask to run
          //Search for the symbolName style items within the ArcGIS 2D style project item.
          var items = arcGIS2DStyle.SearchSymbols(StyleItemType.PointSymbol, "Circle 1");
    
          //Gets the CIMSymbol
          CIMSymbol symbolToUse = items.FirstOrDefault().Symbol;
    
          //Get the renderer of the point feature layer
          CIMSimpleRenderer renderer = featureLayer.GetRenderer() as CIMSimpleRenderer;
    
          //Set symbol's real world setting to be the same as that of the feature layer
          symbolToUse.SetRealWorldUnits(featureLayer.UsesRealWorldSymbolSizes);
    
          //Apply the symbol to the feature layer's current renderer
          renderer.Symbol = symbolToUse.MakeSymbolReference();
    
          //Apply the renderer to the feature layer
          featureLayer.SetRenderer(renderer);
      }
    How to apply a color ramp from a style to a feature layer
    {
        List<string> fields = new List<string>() { "Field1" };
        //Note: Needs QueuedTask to run
        StyleProjectItem styleToUse =
          Project.Current.GetItems<StyleProjectItem>()
              .FirstOrDefault(s => s.Name == "ColorBrewer Schemes (RGB)");
        if (style == null) return;
        //Note: Needs QueuedTask to run
        var colorRampListFound = styleToUse.SearchColorRamps("Red-Gray (10 Classes)");
        if (colorRampListFound == null || colorRampListFound.Count == 0) return;
        CIMColorRamp cimColorRamp = null;
        CIMRenderer renderer = null;
    
        cimColorRamp = colorRampListFound[0].ColorRamp;
        var rendererDef = new UniqueValueRendererDefinition(fields, null, cimColorRamp);
        renderer = featureLayer?.CreateRenderer(rendererDef);
        featureLayer?.SetRenderer(renderer);
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also