public static SlopeData FromEntity(Entity ent) { var data = new SlopeData() { FullyCalculated = false }; if (ent.ExtensionDictionary.IsNull) { return(data); } // 总的字典 var extensionDict = ent.ExtensionDictionary.GetObject(OpenMode.ForRead) as DBDictionary; int baseId; // 一般数据 var rec = SymbolTableUtils.GetDictionaryValue <Xrecord>(extensionDict, DictKey_General); if (rec == null) { return(data); } var buffs = rec.Data.AsArray(); try { data.FullyCalculated = Utils.GetExtendedDataBool(buffs[0]); data.CenterAxisHandle = Utils.ConvertToHandle(buffs[1].Value.ToString()); data.FillCut = Utils.GetExtendedDataBool(buffs[2]); data.Station = (double)buffs[3].Value; data.OnLeft = Utils.GetExtendedDataBool(buffs[4]); data.SoilOrRock = Utils.GetExtendedDataEnum <SubgradeType>(buffs[5]);// (SubgradeType)Enum.ToObject(typeof(SubgradeType), (short)buffs[5].Value); // 标高与长度 baseId = 5; data.TopElevation = (double)buffs[baseId + 1].Value; data.BottomElevation = (double)buffs[baseId + 2].Value; data.RetainingWallHeight = (double)buffs[baseId + 3].Value; //data.SlopeLengthBelowWaterLevel = (double)buffs[baseId + 3].Value; //data.SlopeLengthBelowFillTop = (double)buffs[baseId + 4].Value; } catch (Exception ex) { Debug.Print("数据转换出错:" + ex.Message + "\r\n" + ex.StackTrace); } // 边坡 var dbSlopes = SymbolTableUtils.GetDictionaryValue <DBDictionary>(extensionDict, DictKey_Slopes); if (dbSlopes != null) { for (int i = 0; i < dbSlopes.Count; i++) { var v = SymbolTableUtils.GetDictionaryValue <Xrecord>(dbSlopes, i.ToString()); var slp = Slope.FromResultBuffer(v.Data); if (slp != null) { data.Slopes.Add(slp); } } } // 平台 var dbPlatforms = SymbolTableUtils.GetDictionaryValue <DBDictionary>(extensionDict, DictKey_Platforms); if (dbPlatforms != null) { for (int i = 0; i < dbPlatforms.Count; i++) { var v = SymbolTableUtils.GetDictionaryValue <Xrecord>(dbPlatforms, i.ToString()); var slp = Platform.FromResultBuffer(v.Data); if (slp != null) { data.Platforms.Add(slp); } } } // 水位线 // 一般数据 var wl = SymbolTableUtils.GetDictionaryValue <Xrecord>(extensionDict, DictKey_Waterlines); if (wl == null || wl.Data == null) { return(data); } buffs = wl.Data.AsArray(); var waterlines = buffs.Select(r => Utils.ConvertToHandle(r.Value.ToString())).ToList(); data.Waterlines = waterlines; // return(data); }