| | |
| | | using System.Transactions; |
| | | |
| | | namespace HStation.Service |
| | | namespace HStation.Service |
| | | { |
| | | /// <summary> |
| | | /// Revit Json辅助类 |
| | |
| | | /// <summary> |
| | | /// 从json字符串中解析 |
| | | /// </summary> |
| | | public static HStation.Model.RevitModel FromJsonString(string revitJsonString, out string msg) |
| | | public static HStation.Model.RevitModel FromJsonString |
| | | ( |
| | | string revitJsonString, |
| | | string revitOthersJsonString, |
| | | out string msg |
| | | ) |
| | | { |
| | | msg = string.Empty; |
| | | if (string.IsNullOrEmpty(revitJsonString)) |
| | |
| | | { |
| | | var model = new Model.RevitModel(); |
| | | |
| | | //解析结构json |
| | | var jarray = JArray.Parse(revitJsonString); |
| | | for (int i = 0; i < jarray.Count; i++) |
| | | { |
| | |
| | | { |
| | | case RevitJsonCatalog.Reservoir: |
| | | { |
| | | var reservoir = new Model.RevitReservoir(); |
| | | reservoir.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | reservoir.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(reservoir.Code)) |
| | | var reservoir = ParseReservoir(jobject); |
| | | if (reservoir != null) |
| | | { |
| | | reservoir.Code = reservoir.Id; |
| | | model.Reservoirs.Add(reservoir); |
| | | } |
| | | reservoir.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | reservoir.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | reservoir.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | reservoir.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | reservoir.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | reservoir.Quality = quality; |
| | | } |
| | | reservoir.Position = reservoir.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.PoolElev].MatchNumeric(out double poolElev)) |
| | | { |
| | | reservoir.PoolElev = poolElev; |
| | | } |
| | | if (jobject[RevitJsonProp.Head].MatchNumeric(out double head)) |
| | | { |
| | | reservoir.Head = head; |
| | | } |
| | | reservoir.HeadPattern = jobject[RevitJsonProp.HeadPattern].ToString(); |
| | | model.Reservoirs.Add(reservoir); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Tank: |
| | | { |
| | | var tank = new Model.RevitTank(); |
| | | tank.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | tank.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(tank.Code)) |
| | | var tank = ParseTank(jobject); |
| | | if (tank != null) |
| | | { |
| | | tank.Code = tank.Id; |
| | | model.Tanks.Add(tank); |
| | | } |
| | | tank.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | tank.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | tank.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | tank.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | tank.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | tank.Quality = quality; |
| | | } |
| | | tank.Position = tank.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.PoolElev].MatchNumeric(out double poolElev)) |
| | | { |
| | | tank.PoolElev = poolElev; |
| | | } |
| | | if (jobject[RevitJsonProp.InitLevel].MatchNumeric(out double initLevel)) |
| | | { |
| | | tank.InitLevel = initLevel; |
| | | } |
| | | if (jobject[RevitJsonProp.MinLevel].MatchNumeric(out double minLevel)) |
| | | { |
| | | tank.MinLevel = minLevel; |
| | | } |
| | | if (jobject[RevitJsonProp.MaxLevel].MatchNumeric(out double maxLevel)) |
| | | { |
| | | tank.MaxLevel = maxLevel; |
| | | } |
| | | if (jobject[RevitJsonProp.Diameter].MatchNumeric(out double diameter)) |
| | | { |
| | | tank.Diameter = diameter; |
| | | } |
| | | if (jobject[RevitJsonProp.MinVol].MatchNumeric(out double minVol)) |
| | | { |
| | | tank.MinVol = minVol; |
| | | } |
| | | tank.VolCurve = jobject[RevitJsonProp.VolCurve].ToString(); |
| | | model.Tanks.Add(tank); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Waterbox: |
| | | { |
| | | var waterbox = new Model.RevitWaterbox(); |
| | | waterbox.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | waterbox.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(waterbox.Code)) |
| | | var waterbox = ParseWaterbox(jobject); |
| | | if (waterbox != null) |
| | | { |
| | | waterbox.Code = waterbox.Id; |
| | | model.Waterboxs.Add(waterbox); |
| | | } |
| | | waterbox.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | waterbox.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | waterbox.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | waterbox.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | waterbox.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | waterbox.Quality = quality; |
| | | } |
| | | waterbox.Position = waterbox.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.PoolElev].MatchNumeric(out double poolElev)) |
| | | { |
| | | waterbox.PoolElev = poolElev; |
| | | } |
| | | if (jobject[RevitJsonProp.InitLevel].MatchNumeric(out double initLevel)) |
| | | { |
| | | waterbox.InitLevel = initLevel; |
| | | } |
| | | if (jobject[RevitJsonProp.MinLevel].MatchNumeric(out double minLevel)) |
| | | { |
| | | waterbox.MinLevel = minLevel; |
| | | } |
| | | if (jobject[RevitJsonProp.MaxLevel].MatchNumeric(out double maxLevel)) |
| | | { |
| | | waterbox.MaxLevel = maxLevel; |
| | | } |
| | | if (jobject[RevitJsonProp.Diameter].MatchNumeric(out double diameter)) |
| | | { |
| | | waterbox.Diameter = diameter; |
| | | } |
| | | if (jobject[RevitJsonProp.MinVol].MatchNumeric(out double minVol)) |
| | | { |
| | | waterbox.MinVol = minVol; |
| | | } |
| | | waterbox.VolCurve = jobject[RevitJsonProp.VolCurve].ToString(); |
| | | model.Waterboxs.Add(waterbox); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Junction: |
| | | { |
| | | var junction = new Model.RevitJunction(); |
| | | junction.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | junction.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(junction.Code)) |
| | | var junction = ParseJunction(jobject); |
| | | if (junction != null) |
| | | { |
| | | junction.Code = junction.Id; |
| | | model.Junctions.Add(junction); |
| | | } |
| | | junction.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | junction.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | junction.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | junction.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | junction.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | junction.Quality = quality; |
| | | } |
| | | junction.Position = junction.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | junction.Elev = elev; |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | junction.Demand = demand; |
| | | } |
| | | junction.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | model.Junctions.Add(junction); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Elbow: |
| | | { |
| | | var elbow = new Model.RevitElbow(); |
| | | elbow.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | elbow.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(elbow.Code)) |
| | | { |
| | | elbow.Code = elbow.Id; |
| | | } |
| | | elbow.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | elbow.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | elbow.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | elbow.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | elbow.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | elbow.Quality = quality; |
| | | } |
| | | elbow.Position = elbow.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | elbow.Elev = elev; |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | elbow.Demand = demand; |
| | | } |
| | | elbow.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | model.Elbows.Add(elbow); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Threelink: |
| | | { |
| | | var threelink = new Model.RevitThreelink(); |
| | | threelink.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | threelink.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(threelink.Code)) |
| | | { |
| | | threelink.Code = threelink.Id; |
| | | } |
| | | threelink.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | threelink.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | threelink.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | threelink.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | threelink.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | threelink.Quality = quality; |
| | | } |
| | | threelink.Position = threelink.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | threelink.Elev = elev; |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | threelink.Demand = demand; |
| | | } |
| | | threelink.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | model.Threelinks.Add(threelink); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Fourlink: |
| | | { |
| | | var fourlink = new Model.RevitFourlink(); |
| | | fourlink.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | fourlink.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(fourlink.Code)) |
| | | { |
| | | fourlink.Code = fourlink.Id; |
| | | } |
| | | fourlink.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | fourlink.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | fourlink.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | fourlink.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | fourlink.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | fourlink.Quality = quality; |
| | | } |
| | | fourlink.Position = fourlink.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | fourlink.Elev = elev; |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | fourlink.Demand = demand; |
| | | } |
| | | fourlink.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | model.Fourlinks.Add(fourlink); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Meter: |
| | | { |
| | | var meter = new Model.RevitMeter(); |
| | | meter.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | meter.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(meter.Code)) |
| | | { |
| | | meter.Code = meter.Id; |
| | | } |
| | | meter.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | meter.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | meter.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | meter.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | meter.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | meter.Quality = quality; |
| | | } |
| | | meter.Position = meter.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | meter.Elev = elev; |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | meter.Demand = demand; |
| | | } |
| | | meter.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | model.Meters.Add(meter); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Flowmeter: |
| | | { |
| | | var flowmeter = new Model.RevitFlowmeter(); |
| | | flowmeter.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | flowmeter.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(flowmeter.Code)) |
| | | { |
| | | flowmeter.Code = flowmeter.Id; |
| | | } |
| | | flowmeter.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | flowmeter.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | flowmeter.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | flowmeter.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | flowmeter.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | flowmeter.Quality = quality; |
| | | } |
| | | flowmeter.Position = flowmeter.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | flowmeter.Elev = elev; |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | flowmeter.Demand = demand; |
| | | } |
| | | flowmeter.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | model.Flowmeters.Add(flowmeter); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Pressmeter: |
| | | { |
| | | var pressmeter = new Model.RevitPressmeter(); |
| | | pressmeter.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | pressmeter.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(pressmeter.Code)) |
| | | { |
| | | pressmeter.Code = pressmeter.Id; |
| | | } |
| | | pressmeter.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | pressmeter.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | pressmeter.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | pressmeter.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | pressmeter.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | pressmeter.Quality = quality; |
| | | } |
| | | pressmeter.Position = pressmeter.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | pressmeter.Elev = elev; |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | pressmeter.Demand = demand; |
| | | } |
| | | pressmeter.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | model.Pressmeters.Add(pressmeter); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Blunthead: |
| | | { |
| | | var blunthead = new Model.RevitBlunthead(); |
| | | blunthead.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | blunthead.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(blunthead.Code)) |
| | | var blunthead = ParseBlunthead(jobject); |
| | | if (blunthead != null) |
| | | { |
| | | blunthead.Code = blunthead.Id; |
| | | model.Bluntheads.Add(blunthead); |
| | | } |
| | | blunthead.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | blunthead.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | blunthead.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | blunthead.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | blunthead.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Elbow: |
| | | { |
| | | var elbow = ParseElbow(jobject); |
| | | if (elbow != null) |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | blunthead.Quality = quality; |
| | | model.Elbows.Add(elbow); |
| | | } |
| | | blunthead.Position = blunthead.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Threelink: |
| | | { |
| | | var threelink = ParseThreelink(jobject); |
| | | if (threelink != null) |
| | | { |
| | | blunthead.Elev = elev; |
| | | model.Threelinks.Add(threelink); |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Fourlink: |
| | | { |
| | | var fourlink = ParseFourlink(jobject); |
| | | if (fourlink != null) |
| | | { |
| | | blunthead.Demand = demand; |
| | | model.Fourlinks.Add(fourlink); |
| | | } |
| | | blunthead.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | model.Bluntheads.Add(blunthead); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Meter: |
| | | { |
| | | var meter = ParseMeter(jobject); |
| | | if (meter != null) |
| | | { |
| | | model.Meters.Add(meter); |
| | | } |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Flowmeter: |
| | | { |
| | | var flowmeter = ParseFlowmeter(jobject); |
| | | if (flowmeter != null) |
| | | { |
| | | model.Flowmeters.Add(flowmeter); |
| | | } |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Pressmeter: |
| | | { |
| | | var pressmeter = ParsePressmeter(jobject); |
| | | if (pressmeter != null) |
| | | { |
| | | model.Pressmeters.Add(pressmeter); |
| | | } |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Nozzle: |
| | | { |
| | | var nozzle = new Model.RevitNozzle(); |
| | | nozzle.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | nozzle.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(nozzle.Code)) |
| | | var nozzle = ParseNozzle(jobject); |
| | | if (nozzle != null) |
| | | { |
| | | nozzle.Code = nozzle.Id; |
| | | model.Nozzles.Add(nozzle); |
| | | } |
| | | nozzle.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | nozzle.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | nozzle.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | nozzle.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | nozzle.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | nozzle.Quality = quality; |
| | | } |
| | | nozzle.Position = nozzle.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | nozzle.Elev = elev; |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | nozzle.Demand = demand; |
| | | } |
| | | nozzle.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (jobject[RevitJsonProp.CoefficientP].MatchNumeric(out double coeffient)) |
| | | { |
| | | nozzle.Coefficient = coeffient; |
| | | } |
| | | model.Nozzles.Add(nozzle); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Hydrant: |
| | | { |
| | | var hydrant = new Model.RevitHydrant(); |
| | | hydrant.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | hydrant.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(hydrant.Code)) |
| | | var hydrant = ParseHydrant(jobject); |
| | | if (hydrant != null) |
| | | { |
| | | hydrant.Code = hydrant.Id; |
| | | model.Hydrants.Add(hydrant); |
| | | } |
| | | hydrant.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | hydrant.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | hydrant.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | hydrant.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | hydrant.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | hydrant.Quality = quality; |
| | | } |
| | | hydrant.Position = hydrant.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | hydrant.Elev = elev; |
| | | } |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | hydrant.Demand = demand; |
| | | } |
| | | hydrant.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (jobject[RevitJsonProp.CoefficientF].MatchNumeric(out double coeffient)) |
| | | { |
| | | hydrant.Coefficient = coeffient; |
| | | } |
| | | model.Hydrants.Add(hydrant); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Exchanger: |
| | | { |
| | | var exchanger = new Model.RevitExchanger(); |
| | | exchanger.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | exchanger.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(exchanger.Code)) |
| | | { |
| | | exchanger.Code = exchanger.Id; |
| | | } |
| | | exchanger.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | exchanger.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | exchanger.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | exchanger.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | exchanger.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | var startConnect = exchanger.ConnectList.GetStartConnect(); |
| | | var endConnect = exchanger.ConnectList.GetEndConnect(); |
| | | exchanger.StartCode = startConnect.Id; |
| | | exchanger.EndCode = endConnect.Id; |
| | | exchanger.StartPosition = startConnect.Position; |
| | | exchanger.EndPosition = endConnect.Position; |
| | | exchanger.LinkStatus = jobject[RevitJsonProp.LinkStatusPipe].ToString(); |
| | | if (jobject[RevitJsonProp.StartElev].MatchNumeric(out double startElev)) |
| | | { |
| | | exchanger.StartElev = startElev; |
| | | } |
| | | if (jobject[RevitJsonProp.EndElev].MatchNumeric(out double endElev)) |
| | | { |
| | | exchanger.EndElev = endElev; |
| | | } |
| | | if (jobject[RevitJsonProp.StartQuality].MatchNumeric(out double startQuality)) |
| | | { |
| | | exchanger.StartQuality = startQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.EndQuality].MatchNumeric(out double endQuality)) |
| | | { |
| | | exchanger.EndQuality = endQuality; |
| | | } |
| | | |
| | | if (jobject[RevitJsonProp.Length].MatchNumeric(out double length)) |
| | | { |
| | | exchanger.Length = length; |
| | | } |
| | | if (jobject[RevitJsonProp.Diameter].MatchNumeric(out double diameter)) |
| | | { |
| | | exchanger.Diameter = diameter; |
| | | } |
| | | else if (jobject[RevitJsonProp.InternalDiameter].MatchNumeric(out double internalDiameter)) |
| | | { |
| | | exchanger.Diameter = internalDiameter; |
| | | } |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | exchanger.MinorLoss = minorLoss; |
| | | } |
| | | if (jobject[RevitJsonProp.Roughness].MatchNumeric(out double roughness)) |
| | | { |
| | | exchanger.Roughness = roughness; |
| | | } |
| | | if (exchanger.Length <= 0) |
| | | { |
| | | exchanger.Length = exchanger.StartPosition.Distance(exchanger.EndPosition); |
| | | } |
| | | if (exchanger.Diameter < 0.1) |
| | | { |
| | | exchanger.Diameter = 0.1; |
| | | } |
| | | if (exchanger.Roughness < 0.1) |
| | | { |
| | | exchanger.Roughness = 0.1; |
| | | } |
| | | model.Exchangers.Add(exchanger); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Pipe: |
| | | { |
| | | var pipe = new Model.RevitPipe(); |
| | | pipe.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | pipe.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(pipe.Code)) |
| | | var pipe = ParsePipe(jobject); |
| | | if (pipe != null) |
| | | { |
| | | pipe.Code = pipe.Id; |
| | | model.Pipes.Add(pipe); |
| | | } |
| | | pipe.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | pipe.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | pipe.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | pipe.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | pipe.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | var startConnect = pipe.ConnectList.GetStartConnect(); |
| | | var endConnect = pipe.ConnectList.GetEndConnect(); |
| | | pipe.StartCode = startConnect.Id; |
| | | pipe.EndCode = endConnect.Id; |
| | | pipe.StartPosition = startConnect.Position; |
| | | pipe.EndPosition = endConnect.Position; |
| | | pipe.LinkStatus = jobject[RevitJsonProp.LinkStatusPipe].ToString(); |
| | | if (jobject[RevitJsonProp.StartElev].MatchNumeric(out double startElev)) |
| | | { |
| | | pipe.StartElev = startElev; |
| | | } |
| | | if (jobject[RevitJsonProp.EndElev].MatchNumeric(out double endElev)) |
| | | { |
| | | pipe.EndElev = endElev; |
| | | } |
| | | if (jobject[RevitJsonProp.StartQuality].MatchNumeric(out double startQuality)) |
| | | { |
| | | pipe.StartQuality = startQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.EndQuality].MatchNumeric(out double endQuality)) |
| | | { |
| | | pipe.EndQuality = endQuality; |
| | | } |
| | | |
| | | if (jobject[RevitJsonProp.Length].MatchNumeric(out double length)) |
| | | { |
| | | pipe.Length = length; |
| | | } |
| | | if (jobject[RevitJsonProp.Diameter].MatchNumeric(out double diameter)) |
| | | { |
| | | pipe.Diameter = diameter; |
| | | } |
| | | else if (jobject[RevitJsonProp.InternalDiameter].MatchNumeric(out double internalDiameter)) |
| | | { |
| | | pipe.Diameter = internalDiameter; |
| | | } |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | pipe.MinorLoss = minorLoss; |
| | | } |
| | | if (jobject[RevitJsonProp.Roughness].MatchNumeric(out double roughness)) |
| | | { |
| | | pipe.Roughness = roughness; |
| | | } |
| | | if (pipe.Length <= 0) |
| | | { |
| | | pipe.Length = pipe.StartPosition.Distance(pipe.EndPosition); |
| | | } |
| | | if (pipe.Diameter < 0.1) |
| | | { |
| | | pipe.Diameter = 0.1; |
| | | } |
| | | if (pipe.Roughness < 0.1) |
| | | { |
| | | pipe.Roughness = 0.1; |
| | | } |
| | | model.Pipes.Add(pipe); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Translation: |
| | | { |
| | | var translation = new Model.RevitTranslation(); |
| | | translation.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | translation.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(translation.Code)) |
| | | var translation = ParseTranslation(jobject); |
| | | if (translation != null) |
| | | { |
| | | translation.Code = translation.Id; |
| | | model.Translations.Add(translation); |
| | | } |
| | | translation.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | translation.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | translation.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | translation.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | translation.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Exchanger: |
| | | { |
| | | var exchanger = ParseExchanger(jobject); |
| | | if (exchanger != null) |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | var startConnect = translation.ConnectList.GetStartConnect(); |
| | | var endConnect = translation.ConnectList.GetEndConnect(); |
| | | translation.StartCode = startConnect.Id; |
| | | translation.EndCode = endConnect.Id; |
| | | translation.StartPosition = startConnect.Position; |
| | | translation.EndPosition = endConnect.Position; |
| | | translation.LinkStatus = jobject[RevitJsonProp.LinkStatusPipe].ToString(); |
| | | if (jobject[RevitJsonProp.StartElev].MatchNumeric(out double startElev)) |
| | | { |
| | | translation.StartElev = startElev; |
| | | model.Exchangers.Add(exchanger); |
| | | } |
| | | if (jobject[RevitJsonProp.EndElev].MatchNumeric(out double endElev)) |
| | | { |
| | | translation.EndElev = endElev; |
| | | } |
| | | if (jobject[RevitJsonProp.StartQuality].MatchNumeric(out double startQuality)) |
| | | { |
| | | translation.StartQuality = startQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.EndQuality].MatchNumeric(out double endQuality)) |
| | | { |
| | | translation.EndQuality = endQuality; |
| | | } |
| | | |
| | | if (jobject[RevitJsonProp.Length].MatchNumeric(out double length)) |
| | | { |
| | | translation.Length = length; |
| | | } |
| | | if (jobject[RevitJsonProp.Diameter].MatchNumeric(out double diameter)) |
| | | { |
| | | translation.Diameter = diameter; |
| | | } |
| | | else if (jobject[RevitJsonProp.InternalDiameter].MatchNumeric(out double internalDiameter)) |
| | | { |
| | | translation.Diameter = internalDiameter; |
| | | } |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | translation.MinorLoss = minorLoss; |
| | | } |
| | | if (jobject[RevitJsonProp.Roughness].MatchNumeric(out double roughness)) |
| | | { |
| | | translation.Roughness = roughness; |
| | | } |
| | | if (translation.Length <= 0) |
| | | { |
| | | translation.Length = translation.StartPosition.Distance(translation.EndPosition); |
| | | } |
| | | if (translation.Diameter < 0.1) |
| | | { |
| | | translation.Diameter = 0.1; |
| | | } |
| | | if (translation.Roughness < 0.1) |
| | | { |
| | | translation.Roughness = 0.1; |
| | | } |
| | | model.Translations.Add(translation); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Pump: |
| | | { |
| | | var pump = new Model.RevitPump(); |
| | | pump.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | pump.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(pump.Code)) |
| | | var pump = ParsePump(jobject); |
| | | if (pump != null) |
| | | { |
| | | pump.Code = pump.Id; |
| | | model.Pumps.Add(pump); |
| | | } |
| | | pump.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | pump.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | pump.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | pump.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | pump.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | var startConnect = pump.ConnectList.GetStartConnect(); |
| | | var endConnect = pump.ConnectList.GetEndConnect(); |
| | | pump.StartCode = startConnect.Id; |
| | | pump.EndCode = endConnect.Id; |
| | | pump.StartPosition = startConnect.Position; |
| | | pump.EndPosition = endConnect.Position; |
| | | pump.LinkStatus = jobject[RevitJsonProp.LinkStatusPump].ToString(); |
| | | if (jobject[RevitJsonProp.StartElev].MatchNumeric(out double startElev)) |
| | | { |
| | | pump.StartElev = startElev; |
| | | } |
| | | if (jobject[RevitJsonProp.EndElev].MatchNumeric(out double endElev)) |
| | | { |
| | | pump.EndElev = endElev; |
| | | } |
| | | if (jobject[RevitJsonProp.StartQuality].MatchNumeric(out double startQuality)) |
| | | { |
| | | pump.StartQuality = startQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.EndQuality].MatchNumeric(out double endQuality)) |
| | | { |
| | | pump.EndQuality = endQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.RatedPower].MatchNumeric(out double ratedPower)) |
| | | { |
| | | pump.RatedPower = ratedPower; |
| | | } |
| | | pump.CurveQH = jobject[RevitJsonProp.CurveQH].ToString(); |
| | | if (jobject[RevitJsonProp.SpeedRatio].MatchNumeric(out double speedRatio)) |
| | | { |
| | | pump.SpeedRatio = speedRatio; |
| | | } |
| | | pump.SpeedRatioPattern = jobject[RevitJsonProp.SpeedRatioPattern].ToString(); |
| | | if (jobject[RevitJsonProp.Price].MatchNumeric(out double price)) |
| | | { |
| | | pump.Price = price; |
| | | } |
| | | pump.PricePattern = jobject[RevitJsonProp.PricePattern].ToString(); |
| | | pump.CurveQE = jobject[RevitJsonProp.CurveQE].ToString(); |
| | | model.Pumps.Add(pump); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Valve: |
| | | { |
| | | var valve = new Model.RevitValve(); |
| | | valve.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | valve.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(valve.Code)) |
| | | var valve = ParseValve(jobject); |
| | | if (valve != null) |
| | | { |
| | | valve.Code = valve.Id; |
| | | model.Valves.Add(valve); |
| | | } |
| | | valve.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | valve.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | valve.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | valve.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | valve.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | var startConnect = valve.ConnectList.GetStartConnect(); |
| | | var endConnect = valve.ConnectList.GetEndConnect(); |
| | | valve.StartCode = startConnect.Id; |
| | | valve.EndCode = endConnect.Id; |
| | | valve.StartPosition = startConnect.Position; |
| | | valve.EndPosition = endConnect.Position; |
| | | valve.LinkStatus = jobject[RevitJsonProp.LinkStatusValve].ToString(); |
| | | if (jobject[RevitJsonProp.StartElev].MatchNumeric(out double startElev)) |
| | | { |
| | | valve.StartElev = startElev; |
| | | } |
| | | if (jobject[RevitJsonProp.EndElev].MatchNumeric(out double endElev)) |
| | | { |
| | | valve.EndElev = endElev; |
| | | } |
| | | if (jobject[RevitJsonProp.StartQuality].MatchNumeric(out double startQuality)) |
| | | { |
| | | valve.StartQuality = startQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.EndQuality].MatchNumeric(out double endQuality)) |
| | | { |
| | | valve.EndQuality = endQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.Diameter].MatchNumeric(out double diameter)) |
| | | { |
| | | valve.Diameter = diameter; |
| | | } |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | valve.MinorLoss = minorLoss; |
| | | } |
| | | |
| | | valve.ValveType = jobject[RevitJsonProp.ValveType].ToString(); |
| | | valve.ValveSetting = jobject[RevitJsonProp.ValveSetting].ToString(); |
| | | model.Valves.Add(valve); |
| | | } |
| | | break; |
| | | |
| | | case RevitJsonCatalog.Other: |
| | | { |
| | | var decorator = ParseDecorator(jobject); |
| | | if (decorator != null) |
| | | { |
| | | model.Decorators.Add(decorator); |
| | | } |
| | | } |
| | | break; |
| | | default: break; |
| | | } |
| | | } |
| | | |
| | | //解析其他json |
| | | var jothersArray = JArray.Parse(revitOthersJsonString); |
| | | if (jothersArray != null && jothersArray.Count > 0) |
| | | { |
| | | var allParterList = model.GetAllParters(); |
| | | for (int i = 0; i < jothersArray.Count; i++) |
| | | { |
| | | var jobject = jothersArray[i]; |
| | | var id = jobject[RevitOthersJsonProp.Id]?.ToString(); |
| | | if (string.IsNullOrEmpty(id)) |
| | | { |
| | | continue; |
| | | } |
| | | if (allParterList.Exists(x => x.Id == id)) |
| | | { |
| | | continue; |
| | | } |
| | | if (model.Decorators.Exists(x => x.Id == id)) |
| | | { |
| | | continue; |
| | | } |
| | | var decorator = new Model.RevitDecorator(); |
| | | decorator.Id = id; |
| | | decorator.Code = id; |
| | | decorator.Name = jobject[RevitOthersJsonProp.Name]?.ToString(); |
| | | decorator.Category = jobject[RevitOthersJsonProp.CategoryName]?.ToString(); |
| | | decorator.Decoration = jobject[RevitOthersJsonProp.CategoryID]?.ToString(); |
| | | model.Decorators.Add(decorator); |
| | | } |
| | | } |
| | | |
| | |
| | | /// <summary> |
| | | /// 从json文件中解析 |
| | | /// </summary> |
| | | public static Model.RevitModel FromJsonFile(string revitJsonFile, out string msg) |
| | | public static Model.RevitModel FromJsonFile(string revitJsonFile, string revitOthersJsonFile, out string msg) |
| | | { |
| | | if (!File.Exists(revitJsonFile)) |
| | | { |
| | |
| | | return default; |
| | | } |
| | | var revitJson = File.ReadAllText(revitJsonFile); |
| | | var revitModel = FromJsonString(revitJson, out msg); |
| | | var revitOthersJson = string.Empty; |
| | | if (File.Exists(revitOthersJsonFile)) |
| | | { |
| | | revitOthersJson = File.ReadAllText(revitOthersJsonFile); |
| | | } |
| | | var revitModel = FromJsonString(revitJson, revitOthersJson, out msg); |
| | | if (revitModel == null) |
| | | { |
| | | return default; |
| | |
| | | return revitModel; |
| | | } |
| | | |
| | | //解析连接节点 |
| | | private static HStation.Model.RevitJunction ParseJunction(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | //基础信息 |
| | | var junction = new Model.RevitJunction(); |
| | | junction.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | junction.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(junction.Code)) |
| | | { |
| | | junction.Code = junction.Id; |
| | | } |
| | | junction.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | junction.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | junction.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | junction.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | junction.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | junction.Position = junction.ConnectList.GetCenterPosition(); |
| | | |
| | | //初始水质 |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | junction.Quality = quality; |
| | | } |
| | | |
| | | //标高信息 |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | junction.Elev = elev / 1000f; |
| | | } |
| | | if (junction.Elev <= 0) |
| | | { |
| | | //标高中的高程 |
| | | var jobjectElevOfElevation = jobject[RevitJsonProp.ElevOfElevation]; |
| | | if (jobjectElevOfElevation != null) |
| | | { |
| | | if (jobjectElevOfElevation.MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | junction.Elev = elevOfElevation / 1000f; |
| | | } |
| | | } |
| | | } |
| | | if (junction.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | junction.Elev = junction.Position.Z; |
| | | } |
| | | |
| | | //需水量 |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | junction.Demand = demand; |
| | | } |
| | | |
| | | //需水模式 |
| | | junction.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | |
| | | return junction; |
| | | } |
| | | |
| | | //解析喷头 |
| | | private static HStation.Model.RevitNozzle ParseNozzle(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | //基本信息 |
| | | var nozzle = new Model.RevitNozzle(); |
| | | nozzle.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | nozzle.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(nozzle.Code)) |
| | | { |
| | | nozzle.Code = nozzle.Id; |
| | | } |
| | | nozzle.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | nozzle.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | nozzle.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | nozzle.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | nozzle.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | nozzle.Position = nozzle.ConnectList.GetCenterPosition(); |
| | | |
| | | //初始水质 |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | nozzle.Quality = quality; |
| | | } |
| | | |
| | | //标高信息 |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | nozzle.Elev = elev / 1000f; |
| | | } |
| | | if (nozzle.Elev <= 0) |
| | | { |
| | | //标高中的高程 |
| | | var jobjectElevOfElevation = jobject[RevitJsonProp.ElevOfElevation]; |
| | | if (jobjectElevOfElevation != null) |
| | | { |
| | | if (jobjectElevOfElevation.MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | nozzle.Elev = elevOfElevation / 1000f; |
| | | } |
| | | } |
| | | } |
| | | if (nozzle.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | nozzle.Elev = nozzle.Position.Z; |
| | | } |
| | | |
| | | //需水量 |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | nozzle.Demand = demand; |
| | | } |
| | | |
| | | //需水模式 |
| | | nozzle.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | |
| | | //喷射系数 |
| | | if (jobject[RevitJsonProp.CoefficientP].MatchNumeric(out double coeffient)) |
| | | { |
| | | nozzle.Coefficient = coeffient; |
| | | } |
| | | |
| | | return nozzle; |
| | | } |
| | | |
| | | //解析消火栓 |
| | | private static HStation.Model.RevitHydrant ParseHydrant(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | //基本信息 |
| | | var hydrant = new Model.RevitHydrant(); |
| | | hydrant.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | hydrant.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(hydrant.Code)) |
| | | { |
| | | hydrant.Code = hydrant.Id; |
| | | } |
| | | hydrant.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | hydrant.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | hydrant.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | hydrant.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | hydrant.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | hydrant.Position = hydrant.ConnectList.GetCenterPosition(); |
| | | |
| | | //初始水质 |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | hydrant.Quality = quality; |
| | | } |
| | | |
| | | //标高信息 |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | hydrant.Elev = elev / 1000f; |
| | | } |
| | | if (hydrant.Elev <= 0) |
| | | { |
| | | //标高中的高程 |
| | | var jobjectElevOfElevation = jobject[RevitJsonProp.ElevOfElevation]; |
| | | if (jobjectElevOfElevation != null) |
| | | { |
| | | if (jobjectElevOfElevation.MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | hydrant.Elev = elevOfElevation / 1000f; |
| | | } |
| | | } |
| | | } |
| | | if (hydrant.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | hydrant.Elev = hydrant.Position.Z; |
| | | } |
| | | |
| | | //需水量 |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | hydrant.Demand = demand; |
| | | } |
| | | |
| | | //需水模式 |
| | | hydrant.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | |
| | | //流量系数 |
| | | if (jobject[RevitJsonProp.CoefficientF].MatchNumeric(out double coeffient)) |
| | | { |
| | | hydrant.Coefficient = coeffient; |
| | | } |
| | | |
| | | return hydrant; |
| | | } |
| | | |
| | | //解析弯头 |
| | | private static HStation.Model.RevitElbow ParseElbow(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | //基本信息 |
| | | var elbow = new Model.RevitElbow(); |
| | | elbow.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | elbow.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(elbow.Code)) |
| | | { |
| | | elbow.Code = elbow.Id; |
| | | } |
| | | elbow.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | elbow.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | elbow.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | elbow.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | elbow.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | elbow.Position = elbow.ConnectList.GetCenterPosition(); |
| | | |
| | | //初始水质 |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | elbow.Quality = quality; |
| | | } |
| | | |
| | | //标高信息 |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | elbow.Elev = elev / 1000f; |
| | | } |
| | | if (elbow.Elev <= 0) |
| | | { |
| | | //标高中的高程 |
| | | var jobjectElevOfElevation = jobject[RevitJsonProp.ElevOfElevation]; |
| | | if (jobjectElevOfElevation != null) |
| | | { |
| | | if (jobjectElevOfElevation.MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | elbow.Elev = elevOfElevation / 1000f; |
| | | } |
| | | } |
| | | } |
| | | if (elbow.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | elbow.Elev = elbow.Position.Z; |
| | | } |
| | | |
| | | //需水量 |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | elbow.Demand = demand; |
| | | } |
| | | |
| | | //需水模式 |
| | | elbow.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | |
| | | return elbow; |
| | | } |
| | | |
| | | //解析三通 |
| | | private static HStation.Model.RevitThreelink ParseThreelink(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | //基本信息 |
| | | var threelink = new Model.RevitThreelink(); |
| | | threelink.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | threelink.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(threelink.Code)) |
| | | { |
| | | threelink.Code = threelink.Id; |
| | | } |
| | | threelink.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | threelink.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | threelink.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | threelink.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | threelink.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | threelink.Position = threelink.ConnectList.GetCenterPosition(); |
| | | |
| | | //初始水质 |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | threelink.Quality = quality; |
| | | } |
| | | |
| | | //标高信息 |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | threelink.Elev = elev / 1000f; |
| | | } |
| | | if (threelink.Elev <= 0) |
| | | { |
| | | //标高中的高程 |
| | | var jobjectElevOfElevation = jobject[RevitJsonProp.ElevOfElevation]; |
| | | if (jobjectElevOfElevation != null) |
| | | { |
| | | if (jobjectElevOfElevation.MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | threelink.Elev = elevOfElevation / 1000f; |
| | | } |
| | | } |
| | | } |
| | | if (threelink.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | threelink.Elev = threelink.Position.Z; |
| | | } |
| | | |
| | | //需水量 |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | threelink.Demand = demand; |
| | | } |
| | | |
| | | //需水模式 |
| | | threelink.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | |
| | | return threelink; |
| | | } |
| | | |
| | | //解析四通 |
| | | private static HStation.Model.RevitFourlink ParseFourlink(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | //基本信息 |
| | | var fourlink = new Model.RevitFourlink(); |
| | | fourlink.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | fourlink.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(fourlink.Code)) |
| | | { |
| | | fourlink.Code = fourlink.Id; |
| | | } |
| | | fourlink.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | fourlink.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | fourlink.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | fourlink.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | fourlink.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | fourlink.Position = fourlink.ConnectList.GetCenterPosition(); |
| | | |
| | | //初始水质 |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | fourlink.Quality = quality; |
| | | } |
| | | |
| | | //标高信息 |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | fourlink.Elev = elev / 1000f; |
| | | } |
| | | if (fourlink.Elev <= 0) |
| | | { |
| | | //标高中的高程 |
| | | var jobjectElevOfElevation = jobject[RevitJsonProp.ElevOfElevation]; |
| | | if (jobjectElevOfElevation != null) |
| | | { |
| | | if (jobjectElevOfElevation.MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | fourlink.Elev = elevOfElevation / 1000f; |
| | | } |
| | | } |
| | | } |
| | | if (fourlink.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | fourlink.Elev = fourlink.Position.Z; |
| | | } |
| | | |
| | | //需水量 |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | fourlink.Demand = demand; |
| | | } |
| | | |
| | | //需水模式 |
| | | fourlink.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | |
| | | return fourlink; |
| | | } |
| | | |
| | | //解析闷头 |
| | | private static HStation.Model.RevitBlunthead ParseBlunthead(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | //基本信息 |
| | | var blunthead = new Model.RevitBlunthead(); |
| | | blunthead.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | blunthead.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(blunthead.Code)) |
| | | { |
| | | blunthead.Code = blunthead.Id; |
| | | } |
| | | blunthead.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | blunthead.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | blunthead.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | blunthead.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | blunthead.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | blunthead.Position = blunthead.ConnectList.GetCenterPosition(); |
| | | |
| | | //初始水质 |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | blunthead.Quality = quality; |
| | | } |
| | | |
| | | //标高信息 |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | blunthead.Elev = elev / 1000f; |
| | | } |
| | | if (blunthead.Elev <= 0) |
| | | { |
| | | //标高中的高程 |
| | | var jobjectElevOfElevation = jobject[RevitJsonProp.ElevOfElevation]; |
| | | if (jobjectElevOfElevation != null) |
| | | { |
| | | if (jobjectElevOfElevation.MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | blunthead.Elev = elevOfElevation / 1000f; |
| | | } |
| | | } |
| | | } |
| | | if (blunthead.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | blunthead.Elev = blunthead.Position.Z; |
| | | } |
| | | |
| | | //需水量 |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | blunthead.Demand = demand; |
| | | } |
| | | |
| | | //需水模式 |
| | | blunthead.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | |
| | | return blunthead; |
| | | } |
| | | |
| | | //解析水表 |
| | | private static HStation.Model.RevitMeter ParseMeter(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | //基本信息 |
| | | var meter = new Model.RevitMeter(); |
| | | meter.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | meter.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(meter.Code)) |
| | | { |
| | | meter.Code = meter.Id; |
| | | } |
| | | meter.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | meter.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | meter.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | meter.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | meter.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | meter.Position = meter.ConnectList.GetCenterPosition(); |
| | | |
| | | //初始水质 |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | meter.Quality = quality; |
| | | } |
| | | |
| | | //标高信息 |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | meter.Elev = elev / 1000f; |
| | | } |
| | | if (meter.Elev <= 0) |
| | | { |
| | | //标高中的高程 |
| | | var jobjectElevOfElevation = jobject[RevitJsonProp.ElevOfElevation]; |
| | | if (jobjectElevOfElevation != null) |
| | | { |
| | | if (jobjectElevOfElevation.MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | meter.Elev = elevOfElevation / 1000f; |
| | | } |
| | | } |
| | | } |
| | | if (meter.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | meter.Elev = meter.Position.Z; |
| | | } |
| | | |
| | | //需水量 |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | meter.Demand = demand; |
| | | } |
| | | |
| | | //需水模式 |
| | | meter.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | |
| | | return meter; |
| | | } |
| | | |
| | | //解析流量计 |
| | | private static HStation.Model.RevitFlowmeter ParseFlowmeter(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | //基本信息 |
| | | var flowmeter = new Model.RevitFlowmeter(); |
| | | flowmeter.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | flowmeter.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(flowmeter.Code)) |
| | | { |
| | | flowmeter.Code = flowmeter.Id; |
| | | } |
| | | flowmeter.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | flowmeter.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | flowmeter.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | flowmeter.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | flowmeter.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | flowmeter.Position = flowmeter.ConnectList.GetCenterPosition(); |
| | | |
| | | //初始水质 |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | flowmeter.Quality = quality; |
| | | } |
| | | |
| | | //标高信息 |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | flowmeter.Elev = elev / 1000f; |
| | | } |
| | | if (flowmeter.Elev <= 0) |
| | | { |
| | | //标高中的高程 |
| | | var jobjectElevOfElevation = jobject[RevitJsonProp.ElevOfElevation]; |
| | | if (jobjectElevOfElevation != null) |
| | | { |
| | | if (jobjectElevOfElevation.MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | flowmeter.Elev = elevOfElevation / 1000f; |
| | | } |
| | | } |
| | | } |
| | | if (flowmeter.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | flowmeter.Elev = flowmeter.Position.Z; |
| | | } |
| | | |
| | | //需水量 |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | flowmeter.Demand = demand; |
| | | } |
| | | |
| | | //需水模式 |
| | | flowmeter.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | |
| | | return flowmeter; |
| | | } |
| | | |
| | | //解析压力表 |
| | | private static HStation.Model.RevitPressmeter ParsePressmeter(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | //基本信息 |
| | | var pressmeter = new Model.RevitPressmeter(); |
| | | pressmeter.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | pressmeter.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(pressmeter.Code)) |
| | | { |
| | | pressmeter.Code = pressmeter.Id; |
| | | } |
| | | pressmeter.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | pressmeter.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | pressmeter.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | pressmeter.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | pressmeter.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | pressmeter.Position = pressmeter.ConnectList.GetCenterPosition(); |
| | | |
| | | //初始水质 |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | pressmeter.Quality = quality; |
| | | } |
| | | |
| | | //标高信息 |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | pressmeter.Elev = elev / 1000f; |
| | | } |
| | | if (pressmeter.Elev <= 0) |
| | | { |
| | | //标高中的高程 |
| | | var jobjectElevOfElevation = jobject[RevitJsonProp.ElevOfElevation]; |
| | | if (jobjectElevOfElevation != null) |
| | | { |
| | | if (jobjectElevOfElevation.MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | pressmeter.Elev = elevOfElevation / 1000f; |
| | | } |
| | | } |
| | | } |
| | | if (pressmeter.Elev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | pressmeter.Elev = pressmeter.Position.Z; |
| | | } |
| | | |
| | | //需水量 |
| | | if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) |
| | | { |
| | | pressmeter.Demand = demand; |
| | | } |
| | | |
| | | //需水模式 |
| | | pressmeter.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | |
| | | return pressmeter; |
| | | } |
| | | |
| | | //解析水库 |
| | | private static HStation.Model.RevitReservoir ParseReservoir(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var reservoir = new Model.RevitReservoir(); |
| | | reservoir.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | reservoir.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(reservoir.Code)) |
| | | { |
| | | reservoir.Code = reservoir.Id; |
| | | } |
| | | reservoir.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | reservoir.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | reservoir.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | reservoir.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | reservoir.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | reservoir.Position = reservoir.ConnectList.GetCenterPosition(); |
| | | |
| | | //初始水质 |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | reservoir.Quality = quality; |
| | | } |
| | | |
| | | //池底标高 |
| | | if (jobject[RevitJsonProp.PoolElev].MatchNumeric(out double poolElev)) |
| | | { |
| | | reservoir.PoolElev = poolElev; |
| | | } |
| | | |
| | | //总水头 |
| | | if (jobject[RevitJsonProp.Head].MatchNumeric(out double head)) |
| | | { |
| | | reservoir.Head = head; |
| | | } |
| | | |
| | | //水头模式 |
| | | reservoir.HeadPattern = jobject[RevitJsonProp.HeadPattern].ToString(); |
| | | |
| | | return reservoir; |
| | | } |
| | | |
| | | //解析水池 |
| | | private static HStation.Model.RevitTank ParseTank(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var tank = new Model.RevitTank(); |
| | | tank.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | tank.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(tank.Code)) |
| | | { |
| | | tank.Code = tank.Id; |
| | | } |
| | | tank.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | tank.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | tank.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | tank.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | tank.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | tank.Position = tank.ConnectList.GetCenterPosition(); |
| | | |
| | | //初始水质 |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | tank.Quality = quality; |
| | | } |
| | | |
| | | //标高信息 |
| | | if (jobject[RevitJsonProp.PoolElev].MatchNumeric(out double elev)) |
| | | { |
| | | tank.PoolElev = elev / 1000f; |
| | | } |
| | | if (tank.PoolElev <= 0) |
| | | { |
| | | //标高中的高程 |
| | | var jobjectElevOfElevation = jobject[RevitJsonProp.ElevOfElevation]; |
| | | if (jobjectElevOfElevation != null) |
| | | { |
| | | if (jobjectElevOfElevation.MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | tank.PoolElev = elevOfElevation / 1000f; |
| | | } |
| | | } |
| | | } |
| | | if (tank.PoolElev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | tank.PoolElev = tank.Position.Z; |
| | | } |
| | | |
| | | //初始水位 |
| | | if (jobject[RevitJsonProp.InitLevel].MatchNumeric(out double initLevel)) |
| | | { |
| | | tank.InitLevel = initLevel; |
| | | } |
| | | //最低水位 |
| | | if (jobject[RevitJsonProp.MinLevel].MatchNumeric(out double minLevel)) |
| | | { |
| | | tank.MinLevel = minLevel; |
| | | } |
| | | //最高水位 |
| | | if (jobject[RevitJsonProp.MaxLevel].MatchNumeric(out double maxLevel)) |
| | | { |
| | | tank.MaxLevel = maxLevel; |
| | | } |
| | | //直径 |
| | | if (jobject[RevitJsonProp.Diameter].MatchNumeric(out double diameter)) |
| | | { |
| | | tank.Diameter = diameter; |
| | | } |
| | | //最小容积 |
| | | if (jobject[RevitJsonProp.MinVol].MatchNumeric(out double minVol)) |
| | | { |
| | | tank.MinVol = minVol; |
| | | } |
| | | //容积曲线 |
| | | tank.VolCurve = jobject[RevitJsonProp.VolCurve].ToString(); |
| | | if (!string.IsNullOrEmpty(tank.VolCurve)) |
| | | { |
| | | tank.VolCurve = string.Empty; |
| | | } |
| | | return tank; |
| | | } |
| | | |
| | | //解析水箱 |
| | | private static HStation.Model.RevitWaterbox ParseWaterbox(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var waterbox = new Model.RevitWaterbox(); |
| | | waterbox.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | waterbox.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(waterbox.Code)) |
| | | { |
| | | waterbox.Code = waterbox.Id; |
| | | } |
| | | waterbox.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | waterbox.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | waterbox.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | waterbox.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | waterbox.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | waterbox.Position = waterbox.ConnectList.GetCenterPosition(); |
| | | |
| | | //初始水质 |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | waterbox.Quality = quality; |
| | | } |
| | | |
| | | //标高信息 |
| | | if (jobject[RevitJsonProp.PoolElev].MatchNumeric(out double elev)) |
| | | { |
| | | waterbox.PoolElev = elev / 1000f; |
| | | } |
| | | if (waterbox.PoolElev <= 0) |
| | | { |
| | | //标高中的高程 |
| | | var jobjectElevOfElevation = jobject[RevitJsonProp.ElevOfElevation]; |
| | | if (jobjectElevOfElevation != null) |
| | | { |
| | | if (jobjectElevOfElevation.MatchNumeric(out double elevOfElevation)) |
| | | { |
| | | waterbox.PoolElev = elevOfElevation / 1000f; |
| | | } |
| | | } |
| | | } |
| | | if (waterbox.PoolElev <= 0) |
| | | { |
| | | //通过z轴自动计算 |
| | | waterbox.PoolElev = waterbox.Position.Z; |
| | | } |
| | | |
| | | //初始水位 |
| | | if (jobject[RevitJsonProp.InitLevel].MatchNumeric(out double initLevel)) |
| | | { |
| | | waterbox.InitLevel = initLevel; |
| | | } |
| | | //最低水位 |
| | | if (jobject[RevitJsonProp.MinLevel].MatchNumeric(out double minLevel)) |
| | | { |
| | | waterbox.MinLevel = minLevel; |
| | | } |
| | | //最高水位 |
| | | if (jobject[RevitJsonProp.MaxLevel].MatchNumeric(out double maxLevel)) |
| | | { |
| | | waterbox.MaxLevel = maxLevel; |
| | | } |
| | | //直径 |
| | | if (jobject[RevitJsonProp.Diameter].MatchNumeric(out double diameter)) |
| | | { |
| | | waterbox.Diameter = diameter; |
| | | } |
| | | //最小容积 |
| | | if (jobject[RevitJsonProp.MinVol].MatchNumeric(out double minVol)) |
| | | { |
| | | waterbox.MinVol = minVol; |
| | | } |
| | | //容积曲线 |
| | | waterbox.VolCurve = jobject[RevitJsonProp.VolCurve].ToString(); |
| | | if (!string.IsNullOrEmpty(waterbox.VolCurve)) |
| | | { |
| | | waterbox.VolCurve = string.Empty; |
| | | } |
| | | return waterbox; |
| | | } |
| | | |
| | | //解析管道 |
| | | private static HStation.Model.RevitPipe ParsePipe(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | var pipe = new Model.RevitPipe(); |
| | | pipe.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | pipe.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(pipe.Code)) |
| | | { |
| | | pipe.Code = pipe.Id; |
| | | } |
| | | pipe.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | pipe.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | pipe.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | pipe.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | pipe.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | var startConnect = pipe.ConnectList.GetStartConnect(); |
| | | var endConnect = pipe.ConnectList.GetEndConnect(); |
| | | pipe.StartCode = startConnect.Id; |
| | | pipe.EndCode = endConnect.Id; |
| | | pipe.StartPosition = startConnect.Position; |
| | | pipe.EndPosition = endConnect.Position; |
| | | pipe.LinkStatus = jobject[RevitJsonProp.LinkStatusPipe].ToString(); |
| | | if (string.IsNullOrEmpty(pipe.LinkStatus)) |
| | | { |
| | | pipe.LinkStatus = PipeStatus.Open; |
| | | } |
| | | if (jobject[RevitJsonProp.StartElev].MatchNumeric(out double startElev)) |
| | | { |
| | | pipe.StartElev = startElev; |
| | | } |
| | | if (pipe.StartElev <= 0) |
| | | { |
| | | pipe.StartElev = pipe.StartPosition.Z; |
| | | } |
| | | if (jobject[RevitJsonProp.EndElev].MatchNumeric(out double endElev)) |
| | | { |
| | | pipe.EndElev = endElev; |
| | | } |
| | | if (pipe.EndElev <= 0) |
| | | { |
| | | pipe.EndElev = pipe.EndPosition.Z; |
| | | } |
| | | if (jobject[RevitJsonProp.StartQuality].MatchNumeric(out double startQuality)) |
| | | { |
| | | pipe.StartQuality = startQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.EndQuality].MatchNumeric(out double endQuality)) |
| | | { |
| | | pipe.EndQuality = endQuality; |
| | | } |
| | | |
| | | #region 长度 |
| | | |
| | | if (jobject[RevitJsonProp.Length].MatchNumeric(out double length)) |
| | | { |
| | | pipe.Length = length / 1000f; |
| | | } |
| | | if (pipe.Length <= 0) |
| | | { |
| | | pipe.Length = pipe.StartPosition.Distance(pipe.EndPosition) / 1000f; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 材质 |
| | | |
| | | var jobjectMaterial = jobject[RevitJsonProp.Material]; |
| | | if (jobjectMaterial != null) |
| | | { |
| | | pipe.Material = jobjectMaterial[RevitJsonProp.Name]?.ToString(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | #region 直径 |
| | | |
| | | if (jobject[RevitJsonProp.Diameter].MatchNumeric(out double diameter)) |
| | | { |
| | | pipe.Diameter = diameter; |
| | | } |
| | | |
| | | if (pipe.Diameter < 1) |
| | | { |
| | | if (jobject[RevitJsonProp.InternalDiameter].MatchNumeric(out double internalDiameter)) |
| | | { |
| | | pipe.Diameter = internalDiameter; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | pipe.MinorLoss = minorLoss; |
| | | } |
| | | if (jobject[RevitJsonProp.Roughness].MatchNumeric(out double roughness)) |
| | | { |
| | | pipe.Roughness = roughness; |
| | | } |
| | | |
| | | if (pipe.Diameter < 0.1) |
| | | { |
| | | pipe.Diameter = 500; |
| | | } |
| | | if (pipe.Roughness < 0.1) |
| | | { |
| | | pipe.Roughness = 110; |
| | | } |
| | | return pipe; |
| | | } |
| | | |
| | | //解析过渡件 |
| | | private static HStation.Model.RevitTranslation ParseTranslation(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var translation = new Model.RevitTranslation(); |
| | | translation.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | translation.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(translation.Code)) |
| | | { |
| | | translation.Code = translation.Id; |
| | | } |
| | | translation.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | translation.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | translation.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | translation.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | translation.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | var startConnect = translation.ConnectList.GetStartConnect(); |
| | | var endConnect = translation.ConnectList.GetEndConnect(); |
| | | translation.StartCode = startConnect.Id; |
| | | translation.EndCode = endConnect.Id; |
| | | translation.StartPosition = startConnect.Position; |
| | | translation.EndPosition = endConnect.Position; |
| | | translation.LinkStatus = jobject[RevitJsonProp.LinkStatusPipe].ToString(); |
| | | if (string.IsNullOrEmpty(translation.LinkStatus)) |
| | | { |
| | | translation.LinkStatus = PipeStatus.Open; |
| | | } |
| | | if (jobject[RevitJsonProp.StartElev].MatchNumeric(out double startElev)) |
| | | { |
| | | translation.StartElev = startElev; |
| | | } |
| | | if (translation.StartElev <= 0) |
| | | { |
| | | translation.StartElev = translation.StartPosition.Z; |
| | | } |
| | | if (jobject[RevitJsonProp.EndElev].MatchNumeric(out double endElev)) |
| | | { |
| | | translation.EndElev = endElev; |
| | | } |
| | | if (translation.EndElev <= 0) |
| | | { |
| | | translation.EndElev = translation.EndPosition.Z; |
| | | } |
| | | if (jobject[RevitJsonProp.StartQuality].MatchNumeric(out double startQuality)) |
| | | { |
| | | translation.StartQuality = startQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.EndQuality].MatchNumeric(out double endQuality)) |
| | | { |
| | | translation.EndQuality = endQuality; |
| | | } |
| | | |
| | | #region 长度 |
| | | |
| | | if (jobject[RevitJsonProp.Length].MatchNumeric(out double length)) |
| | | { |
| | | translation.Length = length / 1000f; |
| | | } |
| | | if (translation.Length <= 0) |
| | | { |
| | | translation.Length = translation.StartPosition.Distance(translation.EndPosition) / 1000f; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 直径 |
| | | |
| | | if (jobject[RevitJsonProp.Diameter].MatchNumeric(out double diameter)) |
| | | { |
| | | translation.Diameter = diameter; |
| | | } |
| | | if (translation.Diameter <= 0) |
| | | { |
| | | var jobjectInternalDiameter = jobject[RevitJsonProp.InternalDiameter]; |
| | | if (jobjectInternalDiameter != null) |
| | | { |
| | | if (jobjectInternalDiameter.MatchNumeric(out double internalDiameter)) |
| | | { |
| | | translation.Diameter = internalDiameter; |
| | | } |
| | | } |
| | | } |
| | | if (translation.Diameter <= 0) |
| | | { |
| | | var jobjectNominalDiameter = jobject[RevitJsonProp.NominalDiameter]; |
| | | if (jobjectNominalDiameter != null) |
| | | { |
| | | if (jobjectNominalDiameter.MatchNumeric(out double nominalDiameter)) |
| | | { |
| | | translation.Diameter = nominalDiameter; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (translation.Diameter <= 0) |
| | | { |
| | | translation.Diameter = 150; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | translation.MinorLoss = minorLoss; |
| | | } |
| | | if (jobject[RevitJsonProp.Roughness].MatchNumeric(out double roughness)) |
| | | { |
| | | translation.Roughness = roughness; |
| | | } |
| | | if (translation.Roughness < 0.1) |
| | | { |
| | | translation.Roughness = 110; |
| | | } |
| | | |
| | | |
| | | return translation; |
| | | } |
| | | |
| | | //解析换热器 |
| | | private static HStation.Model.RevitExchanger ParseExchanger(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var exchanger = new Model.RevitExchanger(); |
| | | exchanger.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | exchanger.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(exchanger.Code)) |
| | | { |
| | | exchanger.Code = exchanger.Id; |
| | | } |
| | | exchanger.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | exchanger.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | exchanger.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | exchanger.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | exchanger.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | var startConnect = exchanger.ConnectList.GetStartConnect(); |
| | | var endConnect = exchanger.ConnectList.GetEndConnect(); |
| | | exchanger.StartCode = startConnect.Id; |
| | | exchanger.EndCode = endConnect.Id; |
| | | exchanger.StartPosition = startConnect.Position; |
| | | exchanger.EndPosition = endConnect.Position; |
| | | exchanger.LinkStatus = jobject[RevitJsonProp.LinkStatusPipe].ToString(); |
| | | if (string.IsNullOrEmpty(exchanger.LinkStatus)) |
| | | { |
| | | exchanger.LinkStatus = PipeStatus.Open; |
| | | } |
| | | if (jobject[RevitJsonProp.StartElev].MatchNumeric(out double startElev)) |
| | | { |
| | | exchanger.StartElev = startElev; |
| | | } |
| | | if (exchanger.StartElev <= 0) |
| | | { |
| | | exchanger.StartElev = exchanger.StartPosition.Z; |
| | | } |
| | | if (jobject[RevitJsonProp.EndElev].MatchNumeric(out double endElev)) |
| | | { |
| | | exchanger.EndElev = endElev; |
| | | } |
| | | if (exchanger.EndElev <= 0) |
| | | { |
| | | exchanger.EndElev = exchanger.EndPosition.Z; |
| | | } |
| | | if (jobject[RevitJsonProp.StartQuality].MatchNumeric(out double startQuality)) |
| | | { |
| | | exchanger.StartQuality = startQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.EndQuality].MatchNumeric(out double endQuality)) |
| | | { |
| | | exchanger.EndQuality = endQuality; |
| | | } |
| | | |
| | | if (jobject[RevitJsonProp.Length].MatchNumeric(out double length)) |
| | | { |
| | | exchanger.Length = length / 1000f; |
| | | } |
| | | if (exchanger.Length <= 0) |
| | | { |
| | | exchanger.Length = exchanger.StartPosition.Distance(exchanger.EndPosition) / 1000f; |
| | | } |
| | | |
| | | if (jobject[RevitJsonProp.Diameter].MatchNumeric(out double diameter)) |
| | | { |
| | | exchanger.Diameter = diameter; |
| | | } |
| | | if (exchanger.Diameter < 1) |
| | | { |
| | | if (jobject[RevitJsonProp.InternalDiameter].MatchNumeric(out double internalDiameter)) |
| | | { |
| | | exchanger.Diameter = internalDiameter; |
| | | } |
| | | } |
| | | |
| | | if (jobject[RevitJsonProp.Roughness].MatchNumeric(out double roughness)) |
| | | { |
| | | exchanger.Roughness = roughness; |
| | | } |
| | | if (exchanger.Roughness < 0.1) |
| | | { |
| | | exchanger.Roughness = 110; |
| | | } |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | exchanger.MinorLoss = minorLoss; |
| | | } |
| | | if (exchanger.Diameter <= 0) |
| | | { |
| | | exchanger.Diameter = 150; |
| | | } |
| | | |
| | | return exchanger; |
| | | } |
| | | |
| | | //解析水泵 |
| | | private static HStation.Model.RevitPump ParsePump(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | var pump = new Model.RevitPump(); |
| | | pump.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | pump.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(pump.Code)) |
| | | { |
| | | pump.Code = pump.Id; |
| | | } |
| | | pump.Name = jobject[RevitJsonProp.Name].ToString(); |
| | | pump.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | pump.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | pump.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | pump.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | var startConnect = pump.ConnectList.GetStartConnect(); |
| | | var endConnect = pump.ConnectList.GetEndConnect(); |
| | | pump.StartCode = startConnect.Id; |
| | | pump.EndCode = endConnect.Id; |
| | | pump.StartPosition = startConnect.Position; |
| | | pump.EndPosition = endConnect.Position; |
| | | pump.LinkStatus = jobject[RevitJsonProp.LinkStatusPump].ToString(); |
| | | if (string.IsNullOrEmpty(pump.LinkStatus)) |
| | | { |
| | | pump.LinkStatus = PumpStatus.Open; |
| | | } |
| | | if (jobject[RevitJsonProp.StartElev].MatchNumeric(out double startElev)) |
| | | { |
| | | pump.StartElev = startElev; |
| | | } |
| | | if (pump.StartElev <= 0) |
| | | { |
| | | pump.StartElev = pump.StartPosition.Z; |
| | | } |
| | | if (jobject[RevitJsonProp.EndElev].MatchNumeric(out double endElev)) |
| | | { |
| | | pump.EndElev = endElev; |
| | | } |
| | | if (pump.EndElev <= 0) |
| | | { |
| | | pump.EndElev = pump.EndPosition.Z; |
| | | } |
| | | if (jobject[RevitJsonProp.StartQuality].MatchNumeric(out double startQuality)) |
| | | { |
| | | pump.StartQuality = startQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.EndQuality].MatchNumeric(out double endQuality)) |
| | | { |
| | | pump.EndQuality = endQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.RatedPower].MatchNumeric(out double ratedPower)) |
| | | { |
| | | pump.RatedPower = ratedPower; |
| | | } |
| | | pump.CurveQH = jobject[RevitJsonProp.CurveQH].ToString(); |
| | | pump.CurveQH = "PumpDefault"; |
| | | if (jobject[RevitJsonProp.SpeedRatio].MatchNumeric(out double speedRatio)) |
| | | { |
| | | pump.SpeedRatio = speedRatio; |
| | | } |
| | | pump.SpeedRatioPattern = jobject[RevitJsonProp.SpeedRatioPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(pump.SpeedRatioPattern)) |
| | | { |
| | | pump.SpeedRatioPattern = string.Empty; |
| | | } |
| | | if (jobject[RevitJsonProp.Price].MatchNumeric(out double price)) |
| | | { |
| | | pump.Price = price; |
| | | } |
| | | pump.PricePattern = jobject[RevitJsonProp.PricePattern].ToString(); |
| | | if (!string.IsNullOrEmpty(pump.PricePattern)) |
| | | { |
| | | pump.PricePattern = string.Empty; |
| | | } |
| | | pump.CurveQE = jobject[RevitJsonProp.CurveQE].ToString(); |
| | | if (!string.IsNullOrEmpty(pump.CurveQE)) |
| | | { |
| | | pump.CurveQE = string.Empty; |
| | | } |
| | | return pump; |
| | | } |
| | | |
| | | //解析阀门 |
| | | private static HStation.Model.RevitValve ParseValve(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | var valve = new Model.RevitValve(); |
| | | |
| | | #region Id |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Id, out string id)) |
| | | { |
| | | valve.Id = id; |
| | | } |
| | | else |
| | | { |
| | | valve.AppendPropStatus(nameof(valve.Id), ePropStatus.Error, "缺少构件编码"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Code |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Code, out string code)) |
| | | { |
| | | valve.Code = code; |
| | | } |
| | | else |
| | | { |
| | | valve.AppendPropStatus(nameof(valve.Code), ePropStatus.Error, "缺少编码"); |
| | | } |
| | | if (string.IsNullOrEmpty(valve.Code)) |
| | | { |
| | | valve.Code = valve.Id; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Name |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Name, out string name)) |
| | | { |
| | | valve.Name = name; |
| | | } |
| | | else |
| | | { |
| | | valve.AppendPropStatus(nameof(valve.Name), ePropStatus.Error, "缺少名称"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ModelType |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) |
| | | { |
| | | valve.ModelType = modelType; |
| | | } |
| | | else |
| | | { |
| | | valve.AppendPropStatus(nameof(valve.ModelType), ePropStatus.Error, "缺少型号信息"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Flags |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) |
| | | { |
| | | valve.Flags = Yw.Untity.FlagsHelper.ToList(flags); |
| | | } |
| | | else |
| | | { |
| | | valve.AppendPropStatus(nameof(valve.Flags), ePropStatus.Error, "缺少标签"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Description |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Description, out string description)) |
| | | { |
| | | valve.Description = description; |
| | | } |
| | | else |
| | | { |
| | | valve.AppendPropStatus(nameof(valve.Description), ePropStatus.Error, "缺少说明信息"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ConnectList |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) |
| | | { |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); |
| | | valve.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | Id = x.ConnectId, |
| | | Direction = x.Dirction, |
| | | Position = new Model.RevitPosition() |
| | | { |
| | | X = x.Point.X / 1000f, |
| | | Y = x.Point.Y / 1000f, |
| | | Z = x.Point.Z / 1000f |
| | | } |
| | | }).ToList(); |
| | | } |
| | | else |
| | | { |
| | | valve.AppendPropStatus(nameof(valve.ConnectList), ePropStatus.Error, "缺少连接列表"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region LinkStatus |
| | | |
| | | if (jobject.ParseString(RevitJsonProp.LinkStatusValve, out string linkStatus)) |
| | | { |
| | | if (string.IsNullOrEmpty(linkStatus)) |
| | | { |
| | | valve.LinkStatus = ValveStatus.Open; |
| | | valve.AppendPropStatus(nameof(valve.LinkStatus), ePropStatus.Lack, "未配置阀门状态"); |
| | | } |
| | | else |
| | | { |
| | | valve.LinkStatus = linkStatus; |
| | | if (linkStatus != ValveStatus.None && linkStatus != ValveStatus.Closed && linkStatus != ValveStatus.Open) |
| | | { |
| | | valve.AppendPropStatus(nameof(valve.LinkStatus), ePropStatus.Error, $"阀门状态配置错误:{linkStatus}"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | valve.AppendPropStatus(nameof(valve.LinkStatus), ePropStatus.Error, "缺少阀门状态"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | |
| | | var startConnect = valve.ConnectList.GetStartConnect(); |
| | | var endConnect = valve.ConnectList.GetEndConnect(); |
| | | valve.StartCode = startConnect.Id; |
| | | valve.EndCode = endConnect.Id; |
| | | valve.StartPosition = startConnect.Position; |
| | | valve.EndPosition = endConnect.Position; |
| | | |
| | | if (string.IsNullOrEmpty(valve.LinkStatus)) |
| | | { |
| | | valve.LinkStatus = ValveStatus.Open; |
| | | } |
| | | if (jobject[RevitJsonProp.StartElev].MatchNumeric(out double startElev)) |
| | | { |
| | | valve.StartElev = startElev; |
| | | } |
| | | if (valve.StartElev <= 0) |
| | | { |
| | | valve.StartElev = valve.StartPosition.Z; |
| | | } |
| | | if (jobject[RevitJsonProp.EndElev].MatchNumeric(out double endElev)) |
| | | { |
| | | valve.EndElev = endElev; |
| | | } |
| | | if (valve.EndElev <= 0) |
| | | { |
| | | valve.EndElev = valve.EndPosition.Z; |
| | | } |
| | | if (jobject[RevitJsonProp.StartQuality].MatchNumeric(out double startQuality)) |
| | | { |
| | | valve.StartQuality = startQuality; |
| | | } |
| | | if (jobject[RevitJsonProp.EndQuality].MatchNumeric(out double endQuality)) |
| | | { |
| | | valve.EndQuality = endQuality; |
| | | } |
| | | |
| | | if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) |
| | | { |
| | | valve.MinorLoss = minorLoss; |
| | | } |
| | | |
| | | #region 直径 |
| | | |
| | | if (jobject[RevitJsonProp.Diameter].MatchNumeric(out double diameter)) |
| | | { |
| | | valve.Diameter = diameter; |
| | | } |
| | | if (valve.Diameter <= 0) |
| | | { |
| | | var jobjectNominalDiameter = jobject[RevitJsonProp.NominalDiameter]; |
| | | if (jobjectNominalDiameter != null) |
| | | { |
| | | if (jobjectNominalDiameter.MatchNumeric(out double nominalDiameter)) |
| | | { |
| | | valve.Diameter = nominalDiameter; |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | valve.ValveType = jobject[RevitJsonProp.ValveType].ToString(); |
| | | if (string.IsNullOrEmpty(valve.ValveType)) |
| | | { |
| | | valve.ValveType = Valve.GPV; |
| | | } |
| | | valve.ValveSetting = jobject[RevitJsonProp.ValveSetting].ToString(); |
| | | if (string.IsNullOrEmpty(valve.ValveSetting)) |
| | | { |
| | | valve.ValveSetting = "GPVDefault"; |
| | | } |
| | | return valve; |
| | | } |
| | | |
| | | //解析装饰件 |
| | | private static HStation.Model.RevitDecorator ParseDecorator(JToken jobject) |
| | | { |
| | | if (jobject == null) |
| | | { |
| | | return default; |
| | | } |
| | | |
| | | var decorator = new Model.RevitDecorator(); |
| | | decorator.Id = jobject[RevitJsonProp.Id].ToString(); |
| | | decorator.Code = jobject[RevitJsonProp.Code].ToString(); |
| | | if (string.IsNullOrEmpty(decorator.Code)) |
| | | { |
| | | decorator.Code = decorator.Id; |
| | | } |
| | | decorator.Name = string.Empty; |
| | | decorator.Category = jobject[RevitJsonProp.ClanAndType][RevitJsonProp.ClanName].ToString(); |
| | | decorator.Decoration = string.Empty; |
| | | return decorator; |
| | | } |
| | | |
| | | } |
| | | } |