Select to view content in your preferred language

Get all Symbols from a .stylx file as .pngs

1078
4
07-31-2022 03:00 PM
LuisKaiser
Emerging Contributor

Hello all,

I have a .stylx file, where are all symbols are stored. I need these symbols as pictures, for example as .png or .svg file. Is there an option to iterate over all symbols and save them as a picture in a special path? 

Thanks for helping

0 Kudos
4 Replies
PreetiMaske
Esri Regular Contributor

Hi there!

You can not get all symbols in a .stylx file in one call. .stylx is a collection of symbols grouped by categories and have keys. Symbol are searched based on categories or keys. You can follow the workflow listed below to get images for symbols in a stylx.

```
//Open stylx file
 SymbolStyle symbolstyle = await SymbolStyle.OpenAsync(@"PathToStylx"); 
// Get all categories and keys in the stylx.
SymbolStyleSearchParameters searchParams = await symbolstyle .GetDefaultSearchParametersAsync(); 
// capture keys in a list
var keys_list = searchParams.Keys.ToList(); 
foreach (var key_item in keys_list)
{
//for each key get the symbol
var sym = await symbolstyle .GetSymbolAsync(keys: new string[] { key_item });  
//generate swatch for the symbol
var symbol_swatch = await sym.CreateSwatchAsync(); 
//create a bitmap that can then be saved locally.
var bitmap_image = await symbol_swatch.ToImageSourceAsync(); 
.... 
// add code to save image locally
}

I also noticed you also posted same question on ArcGIS Maps SDK for Unity
https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/display-symbols-from-stylx-file/m-...

The ArcGIS Maps SDKs for Unity is different from ArcGIS Runtime SDK, they are two completely distinct SDKs. I was wondering if it just a mix up. If not, can you please explain how this question is related your game engine workflow.

0 Kudos
LuisKaiser
Emerging Contributor

Hello PreetiMaske,

 

thanks for your answer.

I explained why I try a mix up of unity 3d and arcgis .net: Display symbols from stylx file - Esri Community

Thanks for your help

 

0 Kudos
LuisKaiser
Emerging Contributor

Hello PreetiMaske,

I have another question. 

I can't execute the line var bitmap_image = await symbol_swatch.ToImageSourceAsync(); because I can't find the method ToImageSourceAsync(); and I don't find this Method in the definition and documentation of the RuntimeImage:

Class RuntimeImage (arcgis.com)

Do you know what I have to do?

Thanks for your help

0 Kudos
ThadTilton
Esri Contributor

Hey Luis!

That's an extension method in Esri.ArcGISRuntime.UI. If you add the following "using" statement to the top of your code file, you should see it.

 

using Esri.ArcGISRuntime.UI;

 

0 Kudos