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?
Solved! Go to Solution.
Solved by Alexander.Rivilis. Go to Solution.
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
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
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.
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.