List of fonts being used in my mxd

3464
5
06-22-2015 06:28 PM
Highlighted
New Contributor II

Hi there,

I have a Multi-scale layer map document with about 500 different map layers.

I'm using Maplex to label my layers. I'd like to double check whether in my document are any 'Arial' fonts in use.

Now I was wondering if there is a simple way of listing all my fonts I am using?

I have grouped all my layers for scale decencies so the list would need to consider that as well.

Is there anybody out there who has got some programming skills and can help me with that?

I tried the Python forum but unfortunately LabelClass—Help | ArcGIS for Desktop​ can not provide the information I am after.

Help would be kindly appreciated.

Thanks a lot.

Pierre

Reply
0 Kudos
5 Replies
Highlighted
Regular Contributor II

This should do it.

Quick sample, only tested with one feature layer in the document so I am not sure how it will react to basemaps or other layer types.

using System;

using System.Collections.Generic;

using System.Text;

using ESRI.ArcGIS.ArcMapUI;

using ESRI.ArcGIS.Carto;

using ESRI.ArcGIS.esriSystem;

namespace MXDFonts

{

    class Program

    {

        private static LicenseInitializer m_AOLicenseInitializer = new MXDFonts.LicenseInitializer();

        private static string pathToMXD = @"C:\Users\alex7370\Desktop\mxdFont.mxd";

        [STAThread()]

        static void Main(string[] args)

        {

            //ESRI License Initializer generated code.

            m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeBasic },

            new esriLicenseExtensionCode[] { esriLicenseExtensionCode.esriLicenseExtensionCodeMLE });

            //ESRI License Initializer generated code.

            IMapDocument map = new MapDocumentClass();

            map.Open(pathToMXD, "");

            for (int i = 0; i < map.MapCount; i++)

            {

                for (int j = 0; j < map.Map.LayerCount; j++)

                {

                   

                    var layer = map.Map.Layer;

                   

                    try

                    {

                        if (layer is IGroupLayer)

                        {

                            for (int z = 0; z < ((ICompositeLayer)layer).Count; z++)

                            {

                                ILayer xLayer = ((ICompositeLayer) layer).Layer;

                                layerFont(xLayer);

                            }

                        }

                        else

                        {

                            layerFont(layer);

                        }

                       

                    }

                    catch (Exception)

                    {

                       

                        Console.WriteLine("Not a feature layer or does not have a layer associated with it.");

                    }

                }

            }

            //Do not make any call to ArcObjects after ShutDownApplication()

            m_AOLicenseInitializer.ShutdownApplication();

        }

        static void layerFont(ILayer layer)

        {

            IFeatureLayer fl = ((IFeatureLayer)layer);

            Console.WriteLine(fl.Name);

            ILayerDrawingDescriptionFactory flDescription = new FeatureLayerDrawingDescriptionFactoryClass();

            ILayerDrawingDescription drawingDescription = flDescription.CreateLayerDrawingDescription(fl);

            for (int k = 0;

                k < ((IFeatureLayerDrawingDescription2)drawingDescription).LabelingDescription

                    .LabelClassDescriptions.Count;

                k++)

            {

                Console.WriteLine(

                    ((IFeatureLayerDrawingDescription2)drawingDescription).LabelingDescription

                        .LabelClassDescriptions.Element.Symbol.Font.Name);

            }

        }

    }

}

Written in C#.

Hope this helps!

Highlighted
New Contributor II

Hi Alexander,

thank you for providing the code.

I'd love to try this one out but how do I go from here?

In the past I was only using Python (arc.py) to run simple scripts using the Python window.

ArcObjects this is now a different story.

Do I have to install a SDK and how do I run the script?

Thanks

Pierre

Reply
0 Kudos
Highlighted
New Contributor II

Hi Alexander,

I did some research and came up with Visual Studio Express. I guess this will help me to compile and run the script you sent me.

I guess I am on the right track here?

Thanks

Pierre

Reply
0 Kudos
Highlighted
New Contributor II

... this is how far I did get.

There are a few error messages on screen I do not understand.

Obviously I am not a programmer.

What did I do wrong?

Any help would be great.

Thanksvisual_studio.JPG

Reply
0 Kudos
Highlighted
New Contributor II

I noticed I need to install the ArcGIS Runtime SDK.

I downloaded and installed the ArcGIS Runtime.NET.

... still no luck of running your code.

visual_studio2.JPG

Thanks

Pierre

Reply
0 Kudos