Tag Archives: Symbology

ArcGIS VBA Import Symbology to Multiple Layers

Sub CopyRenderer()

Dim pMxDoc As IMxDocument
Dim pMap As IMap
Set pMxDoc = Application.Document
Set pMap = pMxDoc.FocusMap

Dim pFromLayer As IGeoFeatureLayer
Dim pToLayer As IGeoFeatureLayer
Set pFromLayer = pMap.Layer(modCommon.GetLayerIndex(“Line10”))
Dim i As Integer

For i = 30 To 143
If TypeOf pMap.Layer(modCommon.GetLayerIndex(“Line” & i)) Is IGeoFeatureLayer Then
Set pToLayer = pMap.Layer(modCommon.GetLayerIndex(“Line” & i))
Set pToLayer.Renderer = pFromLayer.Renderer
End If
Next

pMxDoc.UpdateContents

End Sub

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