AddXData(lwPolyLine, i + 1, "polyId"); //写扩展数据 public Entity AddXData(Entity ent, Object obj, string regapptablename) { ObjectId objId = ent.ObjectId; Database db = HostApplicationServices.WorkingDatabase; Entity retEntity; using (Transaction trans = db.TransactionManager.StartTransaction()) { retEntity = (Entity)trans.GetObject(ent.ObjectId, OpenMode.ForWrite); RegAppTable apptbl = (RegAppTable)trans.GetObject(db.RegAppTableId, OpenMode.ForWrite); if (!apptbl.Has(regapptablename)) { RegAppTableRecord appTblRcd = new RegAppTableRecord(); appTblRcd.Name = regapptablename; apptbl.Add(appTblRcd); trans.AddNewlyCreatedDBObject(appTblRcd, true); } ResultBuffer resBuf = new ResultBuffer(); resBuf.Add(new TypedValue((int)DxfCode.ExtendedDataRegAppName, regapptablename)); resBuf.Add(new TypedValue((int)DxfCode.ExtendedDataAsciiString, obj)); ent.XData = resBuf; trans.Commit(); } return retEntity; } 保存之后关闭再打开,为什么扩展数据里就没有了呢?? |