コード例 #1
0
ファイル: XDataView.cs プロジェクト: vildar82/AcadLib
        public static void View()
        {
            var doc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;

            if (doc == null)
            {
                return;
            }
            var ed = doc.Editor;
            var db = doc.Database;

            var opt = new PromptEntityOptions("\nВыбери приметив:");
            var res = ed.GetEntity(opt);

            if (res.Status == PromptStatus.OK)
            {
                var    sbInfo = new StringBuilder();
                string entName;
                using (var t = db.TransactionManager.StartTransaction())
                {
                    var ent = (Entity)res.ObjectId.GetObject(OpenMode.ForRead, false, true);
                    entName = ent.ToString();
                    if (ent.XData != null)
                    {
                        sbInfo.AppendLine("XData:");
                        foreach (var item in ent.XData)
                        {
                            sbInfo.AppendLine($"    {GetTypeCodeName(item.TypeCode)} = {item.Value}");
                        }
                    }

                    if (!ent.ExtensionDictionary.IsNull)
                    {
                        sbInfo.AppendLine("\nExtensionDictionary:");
                        ExploreDictionary(ent.ExtensionDictionary, ref sbInfo);
                    }

                    if (sbInfo.Length == 0)
                    {
                        ed.WriteMessage("\nНет расширенных данных у {0}", ent);
                        return;
                    }

                    t.Commit();
                }

                var formXdataView = new FormXDataView(sbInfo.ToString(), entName);
                Application.ShowModalDialog(formXdataView);
            }
        }
コード例 #2
0
ファイル: XDataView.cs プロジェクト: vildar82/AcadLib
        public static void View()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;
            if (doc == null) return;
            Editor ed = doc.Editor;
            Database db = doc.Database;

            var opt = new PromptEntityOptions("\nВыбери приметив:");
            var res = ed.GetEntity(opt);
            if (res.Status == PromptStatus.OK)
            {
                StringBuilder sbInfo = new StringBuilder();
                string entName = string.Empty;
                using (var t = db.TransactionManager.StartTransaction())
                {
                    var ent = res.ObjectId.GetObject(OpenMode.ForRead, false, true) as Entity;
                    entName = ent.ToString();
                    if (ent.XData != null)
                    {
                        sbInfo.AppendLine("XData:");
                        foreach (var item in ent.XData)
                        {
                            sbInfo.AppendLine($"    {getTypeCodeName(item.TypeCode)} = {item.Value}");
                        }
                    }
                    if (!ent.ExtensionDictionary.IsNull)
                    {
                        sbInfo.AppendLine("\nExtensionDictionary:");
                        exploreDictionary(ent.ExtensionDictionary, ref sbInfo);
                    }

                    if (sbInfo.Length==0)
                    {
                        ed.WriteMessage("\nНет расширенных данных у {0}", ent);
                        return;
                    }
                    t.Commit();
                }
                FormXDataView formXdataView = new FormXDataView(sbInfo.ToString(), entName);
                Application.ShowModalDialog(formXdataView);
            }
        }