Create Swatch in ArcGIS Pro

167
4
Jump to solution
07-26-2018 11:54 AM
Highlighted
New Contributor III

I'm curious if there is any way in Pro 2.2 to create a Swatch for a given symbol, like you can do today with the WPF Runtime SDK. I didn't see anything obvious when inspecting the various CIM* symbol classes or in the Pro SDK API reference. 

I am wanting to use the symbols the user has specified for certain layers in a WPF UI of my own creation for a consistent look and feel.

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
by Esri Regular Contributor
Esri Regular Contributor

Hi Daniel, 

 This seems to be of 'common' interest, so I added sample code to cover some of the renders here:

https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Exploration/GetSymbolSwatch

View solution in original post

4 Replies
Highlighted
Occasional Contributor

While not ideal, there is at least one work around... ArcGIS.Desktop.Editing.Templates.EditingTemplate contains Task<ImageSource> GeneratePreviewAsync(int width, int height) which will generate a swatch.  So the process would be three fold.

a) Generate a layer rendered with the symbol you want. (maybe you already have one though)

b) Generate a template that falls into that renderer class (again might already have one).

c) Get the preview off that template.

Of course a utility that generated a swatch from a symbol directly would be preferred.(edit. see Charlie's reply on SymbolStyleItem)

Reply
0 Kudos
Highlighted
Esri Contributor

Daniel, you need a SymbolStyleItem. The property in question is "PreviewImage" (inherited from StyleItem).

So....given a symbol....how do you use a SymbolStyleItem to preview it?

...
return QueuedTask.Run(() => {
   CIMSymbol symbol = ....;

   var si = new SymbolStyleItem() {
      Symbol = symbol,
      PatchHeight = 64,
      PatchWidth = 64
   };
   return si.PreviewImage;
});

This is a good topic for a snippet. I'll make sure one gets added.

Highlighted
by Esri Regular Contributor
Esri Regular Contributor

Hi Daniel, 

 This seems to be of 'common' interest, so I added sample code to cover some of the renders here:

https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Exploration/GetSymbolSwatch

View solution in original post

Highlighted
New Contributor III

Thanks for all of the great support, that sample code is exactly what I was looking for!

Reply
0 Kudos