Tag Archives: IGeoFeatureLayer

Change symbology with ArcGIS VBA

How do you change the symbology of features in ArcGIS with VBA?
First, we have to work on IGeoFeatureLayer.
Cast the normal IFeatureLayer As IGeoFeatureLayer.
Then we can call the renderer by
IGeofeatureLayer.Renderer = pSimpleRenderer

where
With pSimpleRenderer
.Label = “State Border”
Set .Symbol = pSFSymbol
End With

and where
With pSFSymbol
.Color = pColor

End With

and where
Dim pColor As IRgbColor
Set pColor = New RgbColor
pColor.RGB = RGB(255, 255, 128)

http://edndoc.esri.com/arcobjects/8.3/?URL=/ArcObjectsOnline/Samples/ArcMap/ChangeRenderer.htm

 

Dim pDoc As IMxDocument
Set pDoc = ThisDocument
Dim pMap As IMap
Set pMap = pDoc.FocusMap

Dim pLayer As ILayer
Set pLayer = pMap.Layer(0)

Dim pFLayer As IFeatureLayer
Set pFLayer = pLayer
Dim pLyr As IGeoFeatureLayer
Set pLyr = pFLayer

‘Create a color
Dim pColor As IRgbColor
Set pColor = New RgbColor
pColor.RGB = RGB(255, 255, 128)

‘Create a symbol
Dim pSFSymbol As ISimpleMarkerSymbol
Set pSFSymbol = New SimpleMarkerSymbol

With pSFSymbol
.Color = pColor

End With

‘Create a renderer
Dim pSimpleRenderer As ISimpleRenderer
Set pSimpleRenderer = New SimpleRenderer

With pSimpleRenderer
.Label = “State Border”
Set .Symbol = pSFSymbol
End With

‘Set the layer’s renderer
Set pLyr.Renderer = pSimpleRenderer

‘ redraw the TOC and the map
pDoc.UpdateContents
pDoc.ActiveView.Refresh

Advertisements