100.8: New MMPK Issue

2005
12
Jump to solution
05-12-2020 08:51 AM
MarkCederholm
Occasional Contributor III

Heads up, looks like 100.8 has introduced a new MMPK problem, centered around GetLegendInfosAsync.  As soon as I can isolate the problem and set up a working example, I'll get it off to tech support.  Has anyone else seen this yet?

"Cannot call this method in this context: Object failed to load, unable to execute task."

This is only happening with a particular MMPK and not the others I work with, so I wouldn't be surprised if it's a symbology issue.

0 Kudos
12 Replies
MichaelBranscomb
Esri Frequent Contributor

Mark,

What changes were required to the data model?

Thanks

Mike

0 Kudos
MarkCederholm
Occasional Contributor III

Annotation symbols are defined in the annotation classes.  Changing the symbol is not allowed, so new classes were created and the old ones removed.

0 Kudos
MarkCederholm
Occasional Contributor III

Here's a workaround, using ArcObjects, that can be applied to the temporary file GDB as part of an automated workflow.  As far as I can tell, it is currently impossible to do the same thing in ArcGIS Pro*, so this change must be applied before the annotation feature class is upgraded.

using System.Collections.Generic;

using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.DataSourcesGDB;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geodatabase;

namespace UpdateAnnoSym
{

	public static class AnnoHelper
	{

		public static void UpdateAnno(string sWorkspacePath, string sAnnoClass)
		{

			// Open workspace and annotation class
			// [Assumes a file GDB]

			IWorkspaceFactory pWSF = new FileGDBWorkspaceFactoryClass();
			IWorkspace pWS = pWSF.OpenFromFile(sWorkspacePath, 0);
			IFeatureWorkspace pFWS = pWS as IFeatureWorkspace;
			IFeatureClass pFC = pFWS.OpenFeatureClass(sAnnoClass);

			// Get the class extension

			object ext = pFC.Extension;
			IAnnotationClassExtension pAnnoExt = ext as IAnnotationClassExtension;

			// Get symbol collection and loop through symbols

			bool bUpdated = false;
			ISymbolCollection pSC = pAnnoExt.SymbolCollection;
			Dictionary<int, ISymbol> SymbolTab = new Dictionary<int, ISymbol>();
			pSC.Reset();
			while (true)
			{

				// Check text symbol for HSL color definition

				ISymbolIdentifier pSI = pSC.Next();
				if (pSI == null)
					break;
				ISymbol pSym = pSI.Symbol;
				ITextSymbol pTextSym = pSym as ITextSymbol;
				IColor pCol = pTextSym.Color;
				if (!(pCol is IHlsColor pHSL))
					continue;

				// Replace with RGB color

				int iID = pSI.ID;
				IClone pClone = pSym as IClone;
				pTextSym = pClone.Clone() as ITextSymbol;
				int iRGB = pHSL.RGB;
				IRgbColor pRGB = new RgbColorClass() { RGB = iRGB };
				pTextSym.Color = pRGB;
				SymbolTab[iID] = pTextSym as ISymbol;
				bUpdated = true;

			}
			if (!bUpdated)
				return;

			// Update annotation classes

			IAnnotateLayerPropertiesCollection pAPC = pAnnoExt.AnnoProperties;
			int iCount = pAPC.Count;
			for (int i = 0; i < iCount; i++)
			{
				pAPC.QueryItem(i, out IAnnotateLayerProperties pAnnoProp, out IElementCollection pPlaced, out IElementCollection pUnplaced);
				ILabelEngineLayerProperties pLabelProp = pAnnoProp as ILabelEngineLayerProperties;
				int iID = pLabelProp.SymbolID;
				if (!SymbolTab.ContainsKey(iID))
					continue;
				pLabelProp.Symbol = SymbolTab[iID] as ITextSymbol;
			}

			// Update symbol collection
			// [Not really necessary?]

			ISymbolCollection2 pSC2 = pSC as ISymbolCollection2;
			foreach (int iID in SymbolTab.Keys)
				pSC2.Replace(iID, SymbolTab[iID]);

			// Save changes

			IAnnoClassAdmin3 pAdmin = pAnnoExt as IAnnoClassAdmin3;
			pAdmin.UpdateProperties();

		}

	}
}
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

*Feel free to vote up this idea if you agree with it: Geoprocessing Toolset for Creating and Manipulating Annotation Feature Classes 

0 Kudos