using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Internal.PropertyInspector;
 
// This line is not mandatory, but improves loading performances
[assembly: CommandClass(typeof(Rivilis.GetLocalizedProperties))]
 
namespace Rivilis
{
  public class GetLocalizedProperties
  {
    [CommandMethod("GetLocProperties")]
    public static void GetLocProperties()
    {
      Document doc = Application.DocumentManager.MdiActiveDocument;
      Editor ed = doc.Editor;
      PromptEntityResult pres = ed.GetEntity("\nВыберите примитив: ");
      if (pres.Status == PromptStatus.OK)
      {
        ed.WriteMessage("\nИмя: {0}",
          ObjectPropertyManagerProperties.GetDisplayName(pres.ObjectId));
        CollectionVector cats =
          ObjectPropertyManagerProperties.GetProperties(pres.ObjectId, false, false);
 
        for (int i = 0; i < cats.Count(); i++)
        {
          using (CategoryCollectable cat = cats.Item(i) as CategoryCollectable)
          {
            ed.WriteMessage("\n\tИмя категории: {0}, \t\tОписание категории: {1}",
              cat.Name, cat.Description);
            CollectionVector props = cat.Properties;
            for (int j = 0; j < props.Count(); j++)
            {
              using (PropertyCollectable prop = props.Item(j) as PropertyCollectable)
              {
                ed.WriteMessage("\n\t\tИмя свойства: {0}\n\t\t\t Описание свойства: {1}, DISPID: {2}",
                  prop.Name, prop.Description, prop.dispid);
              }
            }
          }
        }
      }
    }
  }
}