Correct use of localizedNameId in the CommandMethod attribute

By Stephen Preston

Our AutoCAD .NET Wizard project template downloadable from the AutoCAD Developer Center includes some boilerplate code to demonstrate how to create various command types. The first command definition looks like this:

_            Public Sub MyCommand() ' This method can have any name                ' Put your command code here            End Sub

A common misunderstanding is thinking that the “MyCommandLocal” string is actual localized command name – someone making that mistake will try to edit that string to create a new localized command name. This string is actually the Id of a string resource in the project, and it’s the string resource that contains the localized commandname. You can see this by clicking the ‘Show All Files’ button in the Visual Studio Solution Explorer and double clicking on the myCommands.resx file.

image

This opens up the resource file, where you can edit the resource string:

image

Kean covered this topic back in 2009, and included instructions for creating additional localized resx files to allow your plug-in to support multiple languages. I’m restating it now because we still receive questions on this from time to time.

Once you’ve created your localized plug-in, you can set localized command names in your Autoloader PackageContents.xml file too. For example, here is a <Commands/> group defining a <Command/> that has a global and local name:

<Commands GroupName="ADNPLUGINS">

  <Command Local="BATCHPUBLISH" Global="BATCHPUBLISH" />

</Commands>

You can add additional per local localized names like this:

<Commands GroupName="ADNPLUGINS">

<Command LocalEnu="BATCHPUBLISH_IN_ENGLISH" LocalDeu="BATCHPUBLISH_IN_GERMAN" LocalFra="BATCHPUBLISH_IN_FRENCH" Global="BATCHPUBLISH" />

</Commands>

and so on …


Comments

3 responses to “Correct use of localizedNameId in the CommandMethod attribute”

  1. Thanks for this post Stephen.
    Could you expand on how to support multiple languages? Is it just something we have to designate in the XML file, or does it have to be done in the vb.NET file?
    Steve

  2. Hi Steve. You have to do both. Here’s a link to KEan Walmsley’s post on setting up localized strings for your .NET app – http://through-the-interface.typepad.com/through_the_interface/2009/06/registering-autocad-commands-with-localized-names-using-net.html.

  3. Thanks Stephen.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading