Hello,
I want to read a Layer-File (.stylx) fom disk and get the TextSymbols (with all properties) by Name.
I need this information to generate a AnnotationClass with the right TextSymbols.
Is it possible to do this from a Core.Host C# Application, not as an add-in, and how can I do it?
Thanks a lot
Solved! Go to Solution.
You cannot do this in a corehost application only in an add-in because styles can only be managed within the context of an ArcGIS Pro project. You can create the style from a .stylx input file by using the StyleHelper class: .
//Full path for the new style file (.stylx) to be created
string styleToCreate = @"C:\Temp\NewStyle.stylx";
await QueuedTask.Run(() => StyleHelper.CreateStyle(Project.Current, styleToCreate));
var stylxProjectItem = Project.Current.GetItems<StyleProjectItem>().FirstOrDefault(i => i.Path == styleToCreate);
And then you can use LookupItem to find specific content:
public Task<SymbolStyleItem> GetSymbolFromStyleAsync(StyleProjectItem style, string key)
{
return QueuedTask.Run(() =>
{
if (style == null)
throw new System.ArgumentNullException();
//Search for a specific point symbol in style
SymbolStyleItem item = (SymbolStyleItem)style.LookupItem(StyleItemType.PointSymbol, key);
return item;
});
}
You cannot do this in a corehost application only in an add-in because styles can only be managed within the context of an ArcGIS Pro project. You can create the style from a .stylx input file by using the StyleHelper class: .
//Full path for the new style file (.stylx) to be created
string styleToCreate = @"C:\Temp\NewStyle.stylx";
await QueuedTask.Run(() => StyleHelper.CreateStyle(Project.Current, styleToCreate));
var stylxProjectItem = Project.Current.GetItems<StyleProjectItem>().FirstOrDefault(i => i.Path == styleToCreate);
And then you can use LookupItem to find specific content:
public Task<SymbolStyleItem> GetSymbolFromStyleAsync(StyleProjectItem style, string key)
{
return QueuedTask.Run(() =>
{
if (style == null)
throw new System.ArgumentNullException();
//Search for a specific point symbol in style
SymbolStyleItem item = (SymbolStyleItem)style.LookupItem(StyleItemType.PointSymbol, key);
return item;
});
}