vb.net arcobjects create transparent buffer

3372
4
Jump to solution
09-07-2014 07:14 PM
LiYao
by
New Contributor III

Hi all,

I want to check when a create a buffer on arcmap, how can I make the buffer transparent? I am using vb.net arcobjects.

Any advice will be appreciated.

0 Kudos
1 Solution

Accepted Solutions
RiverTaig1
Occasional Contributor

Actually you can get something that is pretty close to transparency on the ISymbol interface.  So let's say you have created a  graphic element (a IFillShapeElement could be a polygon or a rectangle as shown below).  You will then find the  the  ISymbol:ROP2 and by setting it equal to esriROPMaskPen, it makes for a nice semi-transparent fill.

    Dim fillShapeEl As IFillShapeElement

    Set fillShapeEl = rect

    Dim sfs As ISimpleFillSymbol

    Set sfs = New SimpleFillSymbol

    Dim rgb As IRgbColor

    Set rgb = New RgbColor

    rgb.Red = 255

    'rgb.Transparency = 50 'This doesn't behave as expected...still 100% opaque

    Dim sym As ISymbol

    Set sym = sfs

    sym.ROP2 = esriROPMaskPen 'This is the magic line!!

    sfs.Color = rgb

    fillShapeEl.Symbol = sfs

    gc.AddElement rect, 0

SemiTransparent.png

View solution in original post

4 Replies
DuncanHornby
MVP Notable Contributor

Li,

Assuming your buffer exists in a layer and is not just some polygon then you can use the interface ILayerEffects to alter the transparency. Only layers support transparency, so if you were intending to create a polygon buffer and display it as a graphic then that will not work.

Duncan

LiYao
by
New Contributor III

Hi Duncan,

Thanks for the reply. I have already create a transparent buffer (for polygon), but now I am unable to remove the colour of the boundary of the buffer.

0 Kudos
RiverTaig1
Occasional Contributor

Actually you can get something that is pretty close to transparency on the ISymbol interface.  So let's say you have created a  graphic element (a IFillShapeElement could be a polygon or a rectangle as shown below).  You will then find the  the  ISymbol:ROP2 and by setting it equal to esriROPMaskPen, it makes for a nice semi-transparent fill.

    Dim fillShapeEl As IFillShapeElement

    Set fillShapeEl = rect

    Dim sfs As ISimpleFillSymbol

    Set sfs = New SimpleFillSymbol

    Dim rgb As IRgbColor

    Set rgb = New RgbColor

    rgb.Red = 255

    'rgb.Transparency = 50 'This doesn't behave as expected...still 100% opaque

    Dim sym As ISymbol

    Set sym = sfs

    sym.ROP2 = esriROPMaskPen 'This is the magic line!!

    sfs.Color = rgb

    fillShapeEl.Symbol = sfs

    gc.AddElement rect, 0

SemiTransparent.png

LiYao
by
New Contributor III

Hi Duncan & Taig,

I have already resolved the issue, thanks a lot for the attention and help.

0 Kudos