We have developed functionality in ArcGIS Pro that lets us create annotations in ArcGIS Pro using the official Norwegian place names registry. The place names registry are presented as a point layer in Pro, and the user can select a place name point and 'push the button' to create an annotation. The annotation is assigned the correct place name registry attributes, and symbology (font, color, size etc) is automatically set based on the type of place name, including the Textstring attribute. However, the first time (and sometimes even the second time) the functionality is used in after starting Pro, the Textstring attribute is set to 'Text' and not the correct place name. 'Text' is the default value when creating a new annotation, and no value is given for Textstring. All other attributes are set correctly.
This problem started when we from ArcGIS Pro 3.4 to 3.5.
The code for creating annotation from place name registry-data looks like this:
private async Task<bool> LagAnnotationFraSSR(SSR_skrivemaate ssr_skrivemaate, string skriftkodetall)
{
bool result = await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
string skriftkode = "Sk" + skriftkodetall;
var fc = m_navnAnnoLayer.GetFeatureClass() as ArcGIS.Core.Data.Mapping.AnnotationFeatureClass;
var label = HentLabelForSkriftkode(fc, skriftkode);
// Finn tekstsymbol-ID for label/annotation class
var symbolName = label.TextSymbol.SymbolName;
var symbolID = HentSymbolIDForLabel(fc, symbolName);
Inspector inspector = m_navnLayer.GetTemplate(skriftkode).Inspector;
var annoProperties = inspector.GetAnnotationProperties();
inspector["AnnotationClassID"] = label.ID;
inspector["SymbolID"] = symbolID;
//THE PROBLEM IS THE FOLLOWING LINE
annoProperties.TextString = ssr_skrivemaate.Valgt_langnavn;
annoProperties.Shape = LagNavnGeometri(ssr_skrivemaate.SSRpunkt);
annoProperties.HorizontalAlignment = ArcGIS.Core.CIM.HorizontalAlignment.Left;
inspector["SKRIVEMAATENUMMER"] = ssr_skrivemaate.Skrivemaatenummer;
inspector["STEDSNUMMER"] = ssr_skrivemaate.Stedsnummer;
inspector["STEDSNAVNNUMMER"] = ssr_skrivemaate.Stedsnavnnummer;
inspector["SKRIVEMATE_ID"] = ssr_skrivemaate.Skrivemaate_ID;
inspector["SPRAK"] = ssr_skrivemaate.Spraak;
inspector["NAVNESTATUS"] = ssr_skrivemaate.Navnestatus;
inspector["NAVNTYPE"] = ssr_skrivemaate.Navneobjekttype_kodeverdi;
inspector["SNAVN"] = ssr_skrivemaate.Valgt_langnavn;
inspector["SKRIFTKODE"] = skriftkodetall;
inspector["OBJTYPE"] = "Tekst";
inspector.SetAnnotationProperties(annoProperties);
var createOperation = new EditOperation();
createOperation.Name = "Lag navn";
createOperation.SelectNewFeatures = true;
createOperation.Create(m_navnLayer.GetTemplate(skriftkode).Layer, inspector);
m_OpprettetFraSSR = true;
return createOperation.Execute();
});
return result;
}