How to updated the color of a annotation feature class programmatically ?

615
2
12-17-2018 09:42 AM
AiminGong
New Contributor II

How to updated the color (all other aspects like font size etc. should remain unchanged) of a annotation feature class programmatically with ArcObject or ArcPy?

0 Kudos
2 Replies
MitchHolley1
MVP Regular Contributor

What have you tried so far?  What software & version are you using?

0 Kudos
AiminGong
New Contributor II

Hello Mitch,

Thank you for your reply! We are currently using ArcGIS 10.3 and are going to upgrade to 10.6, but are primarily using ArcMap (not ArcGIS Pro). We have a number of annoation feature classes (some with millions of features), within each annoation feature class, each annoation has its own font size. To update and produce map for day and night time, we need frequenctly physically update the color of the annoation feature class. As it will be very time consuming to manually update the colour for all the annoation feature classes, we would like to automate this process.

ESRI techincal support has suggested us to use the following code to change the annoation display color in ArcMap, but it does not work for our purpose. We need actually start a editing session and update the color for annoation feature class.

IMxDocument pMx = ArcMap.Document;

           IMap pMap = pMx.FocusMap;

           ILayer pLayer = pMx.SelectedLayer;

           if (pLayer.GetType() == typeof(IAnnotationLayer))

               {

               IAnnotationLayer pAnnoLayer = (IAnnotationLayer)pMx.SelectedLayer;

               ISymbolSubstitution pSymSub = (ISymbolSubstitution)pAnnoLayer;

               pSymSub.SubstituteType = esriSymbolSubstituteType.esriSymbolSubstituteColor;

                IColor pWhite = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(System.Drawing.Color.White); 

               pSymSub.MassColor = pWhite; 

               pMx.ActiveView.Refresh();

               }

           else { MessageBox.Show("Please select the Annotation layer (top level)"); }

 

We were also suggestd to to create a new symbol collection for the annoation feature class and then update the “SymboID” field in the annoation, but we found this not the best way to update the annoation color as we want to make sure all other aspect of the annoation (e.g. reference scale, postiton, font size etc.) remain the same as beofre. The workflow should pretty simple : start a editing session , select all features and update the color and save editing, but I could not find and sample codes to do it programmatically.

Thank you vey much for your help!

0 Kudos