Select to view content in your preferred language

Getting symbols parameters using ArcObjects

390
1
06-01-2022 03:37 PM
drnpb
by
New Contributor

Hi!

I have FeatureClasses (point, line and polygons) with symbology in cartographic representation. How I can get each symbol's parameters (e.g. for polyline: width, colour, style)?

 

part of code

Dim featureClass As IFeatureClass = featureWorkspace.OpenFeatureClass('feature_name')
Dim featureLayer As IFeatureLayer = New FeatureLayer
featureLayer.FeatureClass = featureClass
Dim gfl As IGeoFeatureLayer = featureLayer
Dim pLegInfo As ILegendInfo = featureLayer
'Dim pLineSymb As ICartographicLineSymbol = TryCast(pLegInfo.LegendGroup(0).Class(3).Symbol, ICartographicLineSymbol)

pLineSymb type is IMultiLayerLineSymbol, so

Dim pLineSymb As IMultiLayerLineSymbol = TryCast(pLegInfo.LegendGroup(0).Class(3).Symbol, IMultiLayerLineSymbol)
MsgBox("Color " & pLineSymb.Layer(0).Color.RGB)
MsgBox("Width " & pLineSymb.Layer(0).Width)

0 Kudos
1 Reply
BrentHoskisson
Frequent Contributor

Are you looking for a "pretty name" for the symbol?  Then you can QI to IDisplayName and get the NameString property.

To get the actual attributes, you will have visit all of the interfaces and get the properties.  For example, for ICartographicLineSymbol, you would have to query interface to ILineProperties where you can get the ITemplate information and the ILineDecoration information.  

ArcObjects is very bare-bones, you will not find everything in one place.  The object model diagrams can tell you all the interfaces you need to visit to find all the properties.

Good Luck

Brent Hoskisson

0 Kudos