Сообщество программистов Autodesk в СНГ

ADN Club => AutoCAD .NET API => Тема начата: Алексей Терно от 18-11-2018, 18:02:15

Название: Локализованные имена свойств
Отправлено: Алексей Терно от 18-11-2018, 18:02:15
Для получения локализованных имен объектов можно использовать такой код (источник (https://forums.autodesk.com/t5/net/get-localized-type-names-or-all-geometry-types/m-p/4325573/highlight/true#M35872)):
Код - C# [Выбрать]
  1. [CommandMethod("GetName")]
  2. public static void GetObjName()
  3. {
  4.   Document doc = Application.DocumentManager.MdiActiveDocument;
  5.   Editor ed = doc.Editor;
  6.   PromptEntityResult pres = ed.GetEntity("\nSelect Entity: ");
  7.   if (pres.Status == PromptStatus.OK)
  8.   {
  9.     ed.WriteMessage("\nName: {0}",
  10.       Autodesk.AutoCAD.Internal.PropertyInspector
  11.       .ObjectPropertyManagerProperties.GetDisplayName(pres.ObjectId));
  12.   }
  13. }
  14.  

А как можно получить локализованные имена свойств?
Название: Re: Локализованные имена свойств
Отправлено: Александр Ривилис от 18-11-2018, 20:10:23
А как можно получить локализованные имена свойств?

Код - C# [Выбрать]
  1. using System;
  2. using Autodesk.AutoCAD.Runtime;
  3. using Autodesk.AutoCAD.ApplicationServices;
  4. using Autodesk.AutoCAD.DatabaseServices;
  5. using Autodesk.AutoCAD.Geometry;
  6. using Autodesk.AutoCAD.EditorInput;
  7. using Autodesk.AutoCAD.Internal.PropertyInspector;
  8.  
  9. // This line is not mandatory, but improves loading performances
  10. [assembly: CommandClass(typeof(Rivilis.GetLocalizedProperties))]
  11.  
  12. namespace Rivilis
  13. {
  14.   public class GetLocalizedProperties
  15.   {
  16.     [CommandMethod("GetLocProperties")]
  17.     public static void GetLocProperties()
  18.     {
  19.       Document doc = Application.DocumentManager.MdiActiveDocument;
  20.       Editor ed = doc.Editor;
  21.       PromptEntityResult pres = ed.GetEntity("\nВыберите примитив: ");
  22.       if (pres.Status == PromptStatus.OK)
  23.       {
  24.         ed.WriteMessage("\nИмя: {0}",
  25.           ObjectPropertyManagerProperties.GetDisplayName(pres.ObjectId));
  26.         CollectionVector cats =
  27.           ObjectPropertyManagerProperties.GetProperties(pres.ObjectId, false, false);
  28.  
  29.         for (int i = 0; i < cats.Count(); i++)
  30.         {
  31.           using (CategoryCollectable cat = cats.Item(i) as CategoryCollectable)
  32.           {
  33.             ed.WriteMessage("\n\tИмя категории: {0}, \t\tОписание категории: {1}",
  34.               cat.Name, cat.Description);
  35.             CollectionVector props = cat.Properties;
  36.             for (int j = 0; j < props.Count(); j++)
  37.             {
  38.               using (PropertyCollectable prop = props.Item(j) as PropertyCollectable)
  39.               {
  40.                 ed.WriteMessage("\n\t\tИмя свойства: {0}\n\t\t\t Описание свойства: {1}, DISPID: {2}",
  41.                   prop.Name, prop.Description, prop.dispid);
  42.               }
  43.             }
  44.           }
  45.         }
  46.       }
  47.     }
  48.   }
  49. }


(https://lh3.googleusercontent.com/-GnlFOJbXIIg/W_GcaK3F2AI/AAAAAAAAPRo/XebHFpp1PlAWXykze4ywiERsHbCkAlv2QCHMYCw/s0/clipboard.png)

(https://lh3.googleusercontent.com/-OlptqtR6BzA/W_GczOHHkkI/AAAAAAAAPRw/rqIOlwUi8RUUL0ynDqZhv8_wNW2JP02vACHMYCw/s0/clipboard2.png)


Название: Re: Локализованные имена свойств
Отправлено: Алексей Терно от 22-11-2018, 16:46:47
Александр, двойное Вам спасибо! ))
Прошу прощения, что сразу не ответил.