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

In This Topic
    SetRealWorldUnits Method
    In This Topic
    Sets whether symbol should be displayed with real world size or with fixed screen size.
    Syntax
    Public Shared Sub SetRealWorldUnits( _
       ByVal symbol As CIMSymbol, _
       ByVal realWorldUnits As Boolean _
    ) 
    public static void SetRealWorldUnits( 
       CIMSymbol symbol,
       bool realWorldUnits
    )

    Parameters

    symbol
    ArcGIS.Core.CIM.CIMSymbol
    realWorldUnits
    System.Boolean
    Remarks
    In 3D scenes if a symbol is set to display in real world units, the symbol will display bigger when camera is zoomed in closer to the symbol and will display smaller as the camera zooms away.
    Example
    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