Determining AutoCAD’s language using .NET

To follow on from yesterday's post, today we're going to look at a reliable way to determine the language of the AutoCAD product hosting your .NET module.

Thanks to Troy Louden for sharing this technique. Here's the C# code implementing it:

using System.Globalization;

using Autodesk.AutoCAD.ApplicationServices;

using Autodesk.AutoCAD.Runtime;

 

namespace LanguageInfo

{

  public class Commands

  {

    [CommandMethod("LANG")]

    public static void WhichLanguage()

    {

      var cult =

        new CultureInfo(SystemObjects.DynamicLinker.ProductLcid);

      Application.DocumentManager.MdiActiveDocument.Editor.

        WriteMessage(

          "\nLanguage of your AutoCAD product is {0}.",

          cult.EnglishName

        );

    }

  }

}

When we run the code, we can see it simply tells us the language associated with the product's "culture". We're printing the English version of the name, but the Culture object provides lots more information besides.

Command: LANG

Language of your AutoCAD product is English (United States).

That's it – short and sweet.

And that's also it for the week: all being well my next post will be from San Francisco.

2 responses to “Determining AutoCAD’s language using .NET”

  1. Hi Kean I'm curious how you knew how to find that? I wouldn't even know where to start. If i wanted to find the language and I didn't know how to do it, where would one find out? advice much appreciated. rgds, Ben

    1. Hi Ben,

      As mentioned in the post, this tip was shared by Troy Louden.

      Or did I misunderstand your question?

      Best,

      Kean

Leave a Reply to Kean Walmsley Cancel reply

Your email address will not be published. Required fields are marked *