Select to view content in your preferred language

CharacterMarkerSymbol - Need Triangle 1 and Star 1 symbols

1233
2
08-24-2012 11:47 AM
AkhilParujanwala
Regular Contributor
I am trying to assign my layers in ArcMap with the following symbols from the CharacterMarkerSymbol, Triangle 1 and Star 1.

I know how to use the enumerator of esriSimpleMarkerSymbol, but I can't figure out how to access the Triangle 1 and Star 1 symbols from the CharacterMarkerSymbol and assign it to the layer's symbology.

I can see that there is no enumerator for the CharacterMarkerSymbol class, now I am not sure what to do.

Kindly advise, thanks!
0 Kudos
2 Replies
DuncanHornby
MVP Notable Contributor
Akhil,

The code below will set a layers symbology to Triangle 1 marker.

Duncan

Public Sub Symbolize()
    ' Get Layer
    Dim pMXDoc As IMxDocument
    Set pMXDoc = ThisDocument
    Dim pMap As IMap
    Set pMap = pMXDoc.FocusMap
    Dim pLayer As ILayer
    Set pLayer = pMap.Layer(0)
    Dim pGeoFeatureLayer As IGeoFeatureLayer
    Set pGeoFeatureLayer = pLayer
    
    ' Create a Font
    Dim pFontDisp As IFontDisp
    Set pFontDisp = New stdole.StdFont
    pFontDisp.Bold = True
    pFontDisp.Name = "ESRI Default Marker"
    
    ' Create a character
    Dim pCharacterMarkerSymbol As ICharacterMarkerSymbol
    Set pCharacterMarkerSymbol = New CharacterMarkerSymbol
    With pCharacterMarkerSymbol
        .size = 8
        .Angle = 0
        .Font = pFontDisp
        .CharacterIndex = 35 ' This is Triangle 1
     End With
         
    ' Update renderer, this assumes the renderer is a single feature
    Dim pSimpleRenderer As ISimpleRenderer
    Set pSimpleRenderer = pGeoFeatureLayer.Renderer
    Set pSimpleRenderer.Symbol = pCharacterMarkerSymbol
    Set pGeoFeatureLayer.Renderer = pSimpleRenderer
    
    ' Refresh document
    pMXDoc.UpdateContents
    pMXDoc.ActiveView.Refresh
End Sub
0 Kudos
AkhilParujanwala
Regular Contributor
Thank Hornbydd, that was perfect.

I have posted the C# version of the code below, for future reference
[PHP]
        public static void FieldSketchPointsSymbol(IGeoFeatureLayer pGeoFeatureLayer)
        {
            stdole.IFontDisp pFontDisp;
            pFontDisp = new stdole.StdFontClass() as stdole.IFontDisp;
            pFontDisp.Name = "ESRI Default Marker";

            ICharacterMarkerSymbol pCharacterMarkerSymbol;
            pCharacterMarkerSymbol = new CharacterMarkerSymbolClass();
            pCharacterMarkerSymbol.Size = 18;
            pCharacterMarkerSymbol.Angle = 0;
            pCharacterMarkerSymbol.Color = Utilities.CreateRGBColor(0, 0, 0);
            pCharacterMarkerSymbol.Font = pFontDisp;
            pCharacterMarkerSymbol.CharacterIndex = 94; // 94 is Star 1, 35 is Triangle 1

            ISimpleRenderer pSimpleRenderer;
            pSimpleRenderer = pGeoFeatureLayer.Renderer as ISimpleRenderer;
            pSimpleRenderer.Symbol = pCharacterMarkerSymbol as ISymbol;
            pGeoFeatureLayer.Renderer = pSimpleRenderer as IFeatureRenderer;
        }
[/PHP]

Also, you will need to add the stdole library as a reference, just type "stdole" and it will be the only one.
Here is a reference I used, go to page 4 of the pdf. http://ss.textcube.com/blog/3/30800/attach/XCeXfNzB9r.pdf

To know what CharacterIndex you want, refer to this post: http://forums.arcgis.com/threads/42877-Where-to-find-information-about-character-marker-characterInd....

A quote from mkennedy

/// To find what character index you need for a particular font:
/// 1. Open ArcMap
/// 2. Add in any point dataset
/// 3. Double click on a point symbol in the TOC
/// 4. In the Symbol Selector dialog, click the properties button
/// 5. In the Symbol Property Editor dialog, change the Type to 'Character Marker Symbol'
/// 6. Choose the desired Font
/// 7. Click on the different character symbols to see what Unicode index numer you need


Hope this helps others.

Cheers!
0 Kudos