.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get localized type names or all geometry types

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
835 Views, 3 Replies

Get localized type names or all geometry types

Is it possible to get localized names for AutoCAD .NET geometry types?

For example, I want to get "Полилиния" (in Russian) for Autodesk.AutoCAD.DatabaseServices.Polyline class.

 

If there is no solution, where can I get a list of all geometry types to translate them into another language programmatically?

3 REPLIES 3
Message 2 of 4
Alexander.Rivilis
in reply to: Anonymous

1. Those are not geometrical types but entities types.

2. Next code may help you:

[CommandMethod("GetName")]
public static void GetObjName()
{
  Document doc = Application.DocumentManager.MdiActiveDocument;
  Editor ed = doc.Editor;
  PromptEntityResult pres = ed.GetEntity("\nSelect Entity: ");
  if (pres.Status == PromptStatus.OK)
  {
    ed.WriteMessage("\nName: {0}", 
      Autodesk.AutoCAD.Internal.PropertyInspector
      .ObjectPropertyManagerProperties.GetDisplayName(pres.ObjectId));
  }
}

This code can display name of entity identifying with its ObjectId.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 3 of 4
Hallex
in reply to: Anonymous

In addition to code above, this will return correct entity type:

Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(string.Format("Name:\n{0}",pres.ObjectId.ObjectClass.DxfName));

 So if you clicked light polyline, this code return LWPOLYLINE instead of POLYLINE

as per in Alexander's code

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 4 of 4
moon_pelican_cat
in reply to: Anonymous

More generic way here(only vanilla AutoCAD Entities):

 

How to get the localize type names?

https://forums.autodesk.com/t5/net/how-to-get-the-localize-type-names/m-p/12727133#M81791

(Environment is AutoCAD 2022, but might be applicable for older .nets)

 

It can get the localized names from Type object directly.

Of couse 'GetDisplayName' is faster than the method when it is getting from instances.

The instances are needed to entry in the database, temporary instances is not allowed (like ObjectId.Null)

 

Thanks @Alexander.Rivilis. The answer was getting me a good motivation for the question.

 

@Hallex 

This might be off topic, but I'll be mentioning about an API method chain (I recently recognized):

(not localized and not natural language like, internal type names)

 

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime; // RXClass

[CommandMethod("TESTTYPENAME")]
public static void TestTypeName()
{
    System.Type t;
    t = typeof(Polyline);
    RXClass c = RXClass.GetClass(t);
    Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage($"Name: {c.Name}\n");    // AcDbPolyline
    Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage($"DxfName: {c.DxfName}\n"); // LWPOLYLINE
}

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost