AutoCAD.NET获取实体的ExtendedDataAsciiString扩展数据信息

       public string GetXData(ObjectId entId)
       {
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            Database db = HostApplicationServices.WorkingDatabase;
            String strValueRet = "";

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                Entity ent = (Entity)trans.GetObject(entId, OpenMode.ForRead);
                ResultBuffer rb = ent.XData;
                if (rb != null)
                {
                    foreach (TypedValue entXdata in rb)
                    {
                        if (entXdata.TypeCode == (int)DxfCode.ExtendedDataAsciiString)
                        {
                            strValueRet = entXdata.Value.ToString();
                            break;
                        }
                    }
                }
                trans.Commit();
            }
            return strValueRet;
        }

你可能感兴趣的:(C#,+,AutoCAD)