0

I'm in the process of converting an ArcMap add-in using ArcObjects to use ArcGIS Pro SDK. Not a fun process I must say.

We need to apply symbologies on the fly through code. In ArcObjects I can find the style sheet(.style file), loop through each symbol by name and return an ISymbol object which I can then apply to a ArcMap layer. Is there something similar in Pro SDK? For the life of me I can not find any example anywhere.

I was able to add the style sheet to a Pro project and apply symbols to a layer. With ArcObjects you can basically write code to do anything and everything but I'm not sure if this is the case with Pro SDK.

0

Found a sample code in the link below;

https://github.com/Esri/arcgis-pro-sdk/blob/33fc821f4d107ec646624d13fe133e0a61244f33/Examples/MapAuthoring/CartoFeatures/ProSnippet.cs

Here is the snippet I'm using to apply a symbol from a style sheet to a layer in the map. I added the style sheet to the project I'm using before hand but it can be added at run time it seems. Also I have to stick with VB so please ignore the C# related conversation.

Dim uniqueValueRenderer As CIMUniqueValueRenderer = New CIMUniqueValueRenderer() With {
        .Fields = New String() {"MAP_DIR"}
        }
Dim classes As List(Of CIMUniqueValueClass) = New List(Of CIMUniqueValueClass)()

Dim tsdStyle As StyleProjectItem = Project.Current.GetItems(Of StyleProjectItem)().FirstOrDefault(Function(s) s.Name = "style sheet name")
Dim styleItem As IList(Of SymbolStyleItem)
Dim tickSymbol As CIMSymbol

        ' EAST
        Dim eastValues As List(Of CIMUniqueValue) = New List(Of CIMUniqueValue)()
        Dim eastValue As CIMUniqueValue = New CIMUniqueValue() With {
                .FieldValues = New String() {"E"}
        }
        eastValues.Add(eastValue)
        styleItem = tsdStyle.SearchSymbols(StyleItemType.PointSymbol, "symbol name")
        tickSymbol = styleItem.FirstOrDefault().Symbol
        Dim east = New CIMUniqueValueClass() With {
                .Values = eastValues.ToArray(),
                .Label = "East",
                .Visible = True,
                .Editable = True,
                .Symbol = New CIMSymbolReference() With {
                .Symbol = tickSymbol
                }
        }
        classes.Add(east)
...
...
...
Dim groupOne As CIMUniqueValueGroup = New CIMUniqueValueGroup() With {
                .Heading = "Tics",
                .Classes = classes.ToArray()
        }
uniqueValueRenderer.Groups = New CIMUniqueValueGroup() {groupOne}
uniqueValueRenderer.UseDefaultSymbol = False
| improve this answer | |
  • 3
    Welcome to GIS SE! As a new user please take the tour. Great that you were able to find a solution to your problem - please consider making an edit to your answer to expand it a bit with the specifics that solved the problem. This makes it easier for others with the same or similar problem to find the solution. – Midavalo Mar 3 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.