2

This question already has an answer here:

I am creating an ArcGIS Desktop Add-In that allows the user to draw a polygon and then have it added to the map. I am able to capture the polygon and add it to the map, the issue is the transparency. Currently and by default it is 100% opacity and solid. I want to make it around 50% opacity so the user can see the data behind it.

Here is the ArcObjects 10.3 code I have so far:

     public static void AddPolygonToMap(IActiveView ActiveViewInstance, IGeometry NewGeo)
    {
        //Local Variable Declaration
        var fillShapeElement = default(IFillShapeElement);
        var element = default(IElement);
        var graphicsContainer = default(IGraphicsContainer);
        var simpleFilleSymbol = default(ISimpleFillSymbol);
        var newRgbColor = default(IRgbColor);
        var lineSymbol = default(ILineSymbol);

        //Use the IElement interface to set the Envelope Element's geo
        element = new PolygonElement();
        element.Geometry = NewGeo;

        //QI for the IFillShapeElement interface so that the symbol property can be set
        fillShapeElement = element as IFillShapeElement;

        //Create a new fill symbol
        simpleFilleSymbol = new SimpleFillSymbol();

        //Create a new color marker symbol of the color black;
        newRgbColor = new RgbColor();
        newRgbColor.Red = 0;
        newRgbColor.Green = 0;
        newRgbColor.Blue = 0;

        //Create a new line symbol so that we can set the width outline
        lineSymbol = new SimpleLineSymbol();
        lineSymbol.Color = newRgbColor;
        lineSymbol.Width = 2;

        //Setup the Simple Fill Symbol
        simpleFilleSymbol.Color = newRgbColor;
        simpleFilleSymbol.Style = esriSimpleFillStyle.esriSFSHollow;
        simpleFilleSymbol.Outline = lineSymbol;
        fillShapeElement.Symbol = simpleFilleSymbol;

        //QI for the graphics container from the active view allows access to basic graphics layer
        graphicsContainer = ActiveViewInstance as IGraphicsContainer;

        //Add the new element at Z order 0
        graphicsContainer.AddElement((IElement)fillShapeElement, 0);

        //Show the new graphic
        ActiveViewInstance.Refresh();
    }

marked as duplicate by vinayan, Mapperz Aug 14 '15 at 18:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • See my reply to this question you left on the GeoNet website. – Hornbydd Jul 20 '15 at 15:30
  • @Hornbydd I looked at the VB code you referenced by the issue is I want something around the 50% transparent not 100% transparent and I know the IColor only support a value of 0 or 255. – corky52547 Jul 20 '15 at 15:37