| | |
| | | namespace HStation.Service |
| | | using System.Transactions; |
| | | |
| | | namespace HStation.Service |
| | | { |
| | | /// <summary> |
| | | /// Revit Json辅助类 |
| | |
| | | /// <summary> |
| | | /// 从json字符串中解析 |
| | | /// </summary> |
| | | /// <param name="revitJsonString">json字符串</param> |
| | | /// <returns>格式错误,会抛出异常</returns> |
| | | 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++) |
| | | { |
| | |
| | | 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; |
| | | } |
| | | var linkList = JsonHelper.Json2Object<List<RevitJsonLinkerModel>>(jobject[RevitJsonProp.Links].ToString()); |
| | | var centerPoint = linkList.GetCenterPoint(); |
| | | reservoir.Position = new Model.RevitPosition() |
| | | { |
| | | X = centerPoint.X, |
| | | Y = centerPoint.Y, |
| | | Z = centerPoint.Z |
| | | }; |
| | | reservoir.Position = reservoir.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.PoolElev].MatchNumeric(out double poolElev)) |
| | | { |
| | | reservoir.PoolElev = poolElev; |
| | |
| | | reservoir.Head = head; |
| | | } |
| | | reservoir.HeadPattern = jobject[RevitJsonProp.HeadPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(reservoir.HeadPattern)) |
| | | { |
| | | reservoir.HeadPattern = string.Empty; |
| | | } |
| | | model.Reservoirs.Add(reservoir); |
| | | } |
| | | break; |
| | |
| | | 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; |
| | | } |
| | | var linkList = JsonHelper.Json2Object<List<RevitJsonLinkerModel>>(jobject[RevitJsonProp.Links].ToString()); |
| | | var centerPoint = linkList.GetCenterPoint(); |
| | | tank.Position = new Model.RevitPosition() |
| | | { |
| | | X = centerPoint.X, |
| | | Y = centerPoint.Y, |
| | | Z = centerPoint.Z |
| | | }; |
| | | tank.Position = tank.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.PoolElev].MatchNumeric(out double poolElev)) |
| | | { |
| | | tank.PoolElev = poolElev; |
| | |
| | | tank.MinVol = minVol; |
| | | } |
| | | tank.VolCurve = jobject[RevitJsonProp.VolCurve].ToString(); |
| | | if (!string.IsNullOrEmpty(tank.VolCurve)) |
| | | { |
| | | tank.VolCurve = string.Empty; |
| | | } |
| | | model.Tanks.Add(tank); |
| | | } |
| | | break; |
| | |
| | | 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; |
| | | } |
| | | var linkList = JsonHelper.Json2Object<List<RevitJsonLinkerModel>>(jobject[RevitJsonProp.Links].ToString()); |
| | | var centerPoint = linkList.GetCenterPoint(); |
| | | waterbox.Position = new Model.RevitPosition() |
| | | { |
| | | X = centerPoint.X, |
| | | Y = centerPoint.Y, |
| | | Z = centerPoint.Z |
| | | }; |
| | | waterbox.Position = waterbox.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.PoolElev].MatchNumeric(out double poolElev)) |
| | | { |
| | | waterbox.PoolElev = poolElev; |
| | |
| | | waterbox.MinVol = minVol; |
| | | } |
| | | waterbox.VolCurve = jobject[RevitJsonProp.VolCurve].ToString(); |
| | | if (!string.IsNullOrEmpty(waterbox.VolCurve)) |
| | | { |
| | | waterbox.VolCurve = string.Empty; |
| | | } |
| | | model.Waterboxs.Add(waterbox); |
| | | } |
| | | break; |
| | |
| | | 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; |
| | | } |
| | | var linkList = JsonHelper.Json2Object<List<RevitJsonLinkerModel>>(jobject[RevitJsonProp.Links].ToString()); |
| | | var centerPoint = linkList.GetCenterPoint(); |
| | | junction.Position = new Model.RevitPosition() |
| | | { |
| | | X = centerPoint.X, |
| | | Y = centerPoint.Y, |
| | | Z = centerPoint.Z |
| | | }; |
| | | junction.Position = junction.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | junction.Elev = elev; |
| | |
| | | junction.Demand = demand; |
| | | } |
| | | junction.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(junction.DemandPattern)) |
| | | { |
| | | junction.DemandPattern = string.Empty; |
| | | } |
| | | model.Junctions.Add(junction); |
| | | } |
| | | break; |
| | |
| | | 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; |
| | | } |
| | | var linkList = JsonHelper.Json2Object<List<RevitJsonLinkerModel>>(jobject[RevitJsonProp.Links].ToString()); |
| | | var centerPoint = linkList.GetCenterPoint(); |
| | | elbow.Position = new Model.RevitPosition() |
| | | { |
| | | X = centerPoint.X, |
| | | Y = centerPoint.Y, |
| | | Z = centerPoint.Z |
| | | }; |
| | | elbow.Position = elbow.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | elbow.Elev = elev; |
| | |
| | | elbow.Demand = demand; |
| | | } |
| | | elbow.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(elbow.DemandPattern)) |
| | | { |
| | | elbow.DemandPattern = string.Empty; |
| | | } |
| | | model.Elbows.Add(elbow); |
| | | } |
| | | break; |
| | |
| | | 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; |
| | | } |
| | | var linkList = JsonHelper.Json2Object<List<RevitJsonLinkerModel>>(jobject[RevitJsonProp.Links].ToString()); |
| | | var centerPoint = linkList.GetCenterPoint(); |
| | | threelink.Position = new Model.RevitPosition() |
| | | { |
| | | X = centerPoint.X, |
| | | Y = centerPoint.Y, |
| | | Z = centerPoint.Z |
| | | }; |
| | | threelink.Position = threelink.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | threelink.Elev = elev; |
| | |
| | | threelink.Demand = demand; |
| | | } |
| | | threelink.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(threelink.DemandPattern)) |
| | | { |
| | | threelink.DemandPattern = string.Empty; |
| | | } |
| | | model.Threelinks.Add(threelink); |
| | | } |
| | | break; |
| | |
| | | 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; |
| | | } |
| | | var linkList = JsonHelper.Json2Object<List<RevitJsonLinkerModel>>(jobject[RevitJsonProp.Links].ToString()); |
| | | var centerPoint = linkList.GetCenterPoint(); |
| | | fourlink.Position = new Model.RevitPosition() |
| | | { |
| | | X = centerPoint.X, |
| | | Y = centerPoint.Y, |
| | | Z = centerPoint.Z |
| | | }; |
| | | fourlink.Position = fourlink.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | fourlink.Elev = elev; |
| | |
| | | fourlink.Demand = demand; |
| | | } |
| | | fourlink.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(fourlink.DemandPattern)) |
| | | { |
| | | fourlink.DemandPattern = string.Empty; |
| | | } |
| | | model.Fourlinks.Add(fourlink); |
| | | } |
| | | break; |
| | |
| | | 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; |
| | | } |
| | | var linkList = JsonHelper.Json2Object<List<RevitJsonLinkerModel>>(jobject[RevitJsonProp.Links].ToString()); |
| | | var centerPoint = linkList.GetCenterPoint(); |
| | | meter.Position = new Model.RevitPosition() |
| | | { |
| | | X = centerPoint.X, |
| | | Y = centerPoint.Y, |
| | | Z = centerPoint.Z |
| | | }; |
| | | meter.Position = meter.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | meter.Elev = elev; |
| | |
| | | meter.Demand = demand; |
| | | } |
| | | meter.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(meter.DemandPattern)) |
| | | { |
| | | meter.DemandPattern = string.Empty; |
| | | } |
| | | model.Meters.Add(meter); |
| | | } |
| | | break; |
| | |
| | | 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; |
| | | } |
| | | var linkList = JsonHelper.Json2Object<List<RevitJsonLinkerModel>>(jobject[RevitJsonProp.Links].ToString()); |
| | | var centerPoint = linkList.GetCenterPoint(); |
| | | flowmeter.Position = new Model.RevitPosition() |
| | | { |
| | | X = centerPoint.X, |
| | | Y = centerPoint.Y, |
| | | Z = centerPoint.Z |
| | | }; |
| | | flowmeter.Position = flowmeter.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | flowmeter.Elev = elev; |
| | |
| | | flowmeter.Demand = demand; |
| | | } |
| | | flowmeter.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(flowmeter.DemandPattern)) |
| | | { |
| | | flowmeter.DemandPattern = string.Empty; |
| | | } |
| | | model.Flowmeters.Add(flowmeter); |
| | | } |
| | | break; |
| | |
| | | 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; |
| | | } |
| | | var linkList = JsonHelper.Json2Object<List<RevitJsonLinkerModel>>(jobject[RevitJsonProp.Links].ToString()); |
| | | var centerPoint = linkList.GetCenterPoint(); |
| | | pressmeter.Position = new Model.RevitPosition() |
| | | { |
| | | X = centerPoint.X, |
| | | Y = centerPoint.Y, |
| | | Z = centerPoint.Z |
| | | }; |
| | | pressmeter.Position = pressmeter.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | pressmeter.Elev = elev; |
| | |
| | | pressmeter.Demand = demand; |
| | | } |
| | | pressmeter.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(pressmeter.DemandPattern)) |
| | | { |
| | | pressmeter.DemandPattern = string.Empty; |
| | | } |
| | | model.Pressmeters.Add(pressmeter); |
| | | } |
| | | break; |
| | |
| | | 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, |
| | | Y = x.Point.Y, |
| | | Z = x.Point.Z |
| | | } |
| | | }).ToList(); |
| | | if (jobject[RevitJsonProp.Quality].MatchNumeric(out double quality)) |
| | | { |
| | | blunthead.Quality = quality; |
| | | } |
| | | var linkList = JsonHelper.Json2Object<List<RevitJsonLinkerModel>>(jobject[RevitJsonProp.Links].ToString()); |
| | | var centerPoint = linkList.GetCenterPoint(); |
| | | blunthead.Position = new Model.RevitPosition() |
| | | { |
| | | X = centerPoint.X, |
| | | Y = centerPoint.Y, |
| | | Z = centerPoint.Z |
| | | }; |
| | | blunthead.Position = blunthead.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | blunthead.Elev = elev; |
| | |
| | | blunthead.Demand = demand; |
| | | } |
| | | blunthead.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(blunthead.DemandPattern)) |
| | | { |
| | | blunthead.DemandPattern = string.Empty; |
| | | } |
| | | model.Bluntheads.Add(blunthead); |
| | | } |
| | | break; |
| | |
| | | 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; |
| | | } |
| | | var linkList = JsonHelper.Json2Object<List<RevitJsonLinkerModel>>(jobject[RevitJsonProp.Links].ToString()); |
| | | var centerPoint = linkList.GetCenterPoint(); |
| | | nozzle.Position = new Model.RevitPosition() |
| | | { |
| | | X = centerPoint.X, |
| | | Y = centerPoint.Y, |
| | | Z = centerPoint.Z |
| | | }; |
| | | nozzle.Position = nozzle.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | nozzle.Elev = elev; |
| | |
| | | nozzle.Demand = demand; |
| | | } |
| | | nozzle.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(nozzle.DemandPattern)) |
| | | { |
| | | nozzle.DemandPattern = string.Empty; |
| | | } |
| | | if (jobject[RevitJsonProp.CoefficientP].MatchNumeric(out double coeffient)) |
| | | { |
| | | nozzle.Coefficient = coeffient; |
| | |
| | | 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; |
| | | } |
| | | var linkList = JsonHelper.Json2Object<List<RevitJsonLinkerModel>>(jobject[RevitJsonProp.Links].ToString()); |
| | | var centerPoint = linkList.GetCenterPoint(); |
| | | hydrant.Position = new Model.RevitPosition() |
| | | { |
| | | X = centerPoint.X, |
| | | Y = centerPoint.Y, |
| | | Z = centerPoint.Z |
| | | }; |
| | | hydrant.Position = hydrant.ConnectList.GetCenterPosition(); |
| | | if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) |
| | | { |
| | | hydrant.Elev = elev; |
| | |
| | | hydrant.Demand = demand; |
| | | } |
| | | hydrant.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString(); |
| | | if (!string.IsNullOrEmpty(hydrant.DemandPattern)) |
| | | { |
| | | hydrant.DemandPattern = string.Empty; |
| | | } |
| | | if (jobject[RevitJsonProp.CoefficientF].MatchNumeric(out double coeffient)) |
| | | { |
| | | hydrant.Coefficient = coeffient; |
| | | } |
| | | model.Hydrants.Add(hydrant); |
| | | } |
| | | 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)) |
| | | { |
| | | 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 linkList = JsonHelper.Json2Object<List<RevitJsonLinkerModel>>(jobject[RevitJsonProp.Links].ToString()); |
| | | var startLinker = linkList.GetStartLinker(); |
| | | var endLinker = linkList.GetEndLinker(); |
| | | pipe.StartCode = startLinker.ConnectId; |
| | | pipe.EndCode = endLinker.ConnectId; |
| | | pipe.StartPosition = new Model.RevitPosition() |
| | | { |
| | | X = startLinker.Point.X, |
| | | Y = startLinker.Point.Y, |
| | | Z = startLinker.Point.Z |
| | | }; |
| | | pipe.EndPosition = new Model.RevitPosition() |
| | | { |
| | | X = endLinker.Point.X, |
| | | Y = endLinker.Point.Y, |
| | | Z = endLinker.Point.Z |
| | | }; |
| | | 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; |
| | | } |
| | | 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)) |
| | | { |
| | | 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 linkList = JsonHelper.Json2Object<List<RevitJsonLinkerModel>>(jobject[RevitJsonProp.Links].ToString()); |
| | | var startLinker = linkList.GetStartLinker(); |
| | | var endLinker = linkList.GetEndLinker(); |
| | | translation.StartCode = startLinker.ConnectId; |
| | | translation.EndCode = endLinker.ConnectId; |
| | | translation.StartPosition = new Model.RevitPosition() |
| | | { |
| | | X = startLinker.Point.X, |
| | | Y = startLinker.Point.Y, |
| | | Z = startLinker.Point.Z |
| | | }; |
| | | translation.EndPosition = new Model.RevitPosition() |
| | | { |
| | | X = endLinker.Point.X, |
| | | Y = endLinker.Point.Y, |
| | | Z = endLinker.Point.Z |
| | | }; |
| | | translation.LinkStatus = jobject[RevitJsonProp.LinkStatusPipe].ToString(); |
| | | if (jobject[RevitJsonProp.StartElev].MatchNumeric(out double startElev)) |
| | | { |
| | | translation.StartElev = startElev; |
| | | } |
| | | 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; |
| | | } |
| | | model.Translations.Add(translation); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Exchanger: |
| | |
| | | exchanger.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | exchanger.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | exchanger.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var linkList = JsonHelper.Json2Object<List<RevitJsonLinkerModel>>(jobject[RevitJsonProp.Links].ToString()); |
| | | var startLinker = linkList.GetStartLinker(); |
| | | var endLinker = linkList.GetEndLinker(); |
| | | exchanger.StartCode = startLinker.ConnectId; |
| | | exchanger.EndCode = endLinker.ConnectId; |
| | | exchanger.StartPosition = new Model.RevitPosition() |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | exchanger.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | X = startLinker.Point.X, |
| | | Y = startLinker.Point.Y, |
| | | Z = startLinker.Point.Z |
| | | }; |
| | | exchanger.EndPosition = new Model.RevitPosition() |
| | | { |
| | | X = endLinker.Point.X, |
| | | Y = endLinker.Point.Y, |
| | | Z = endLinker.Point.Z |
| | | }; |
| | | 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.Roughness = roughness; |
| | | } |
| | | if (exchanger.Length <= 0) |
| | | { |
| | | exchanger.Length = exchanger.StartPosition.Distance(exchanger.EndPosition); |
| | | } |
| | | if (exchanger.Diameter < 0.1) |
| | | { |
| | | exchanger.Diameter = 500; |
| | | } |
| | | if (exchanger.Roughness < 0.1) |
| | | { |
| | | exchanger.Roughness = 110; |
| | | } |
| | | 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)) |
| | | { |
| | | 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, |
| | | 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; |
| | | } |
| | | |
| | | |
| | | #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.Length <= 0) |
| | | { |
| | | pipe.Length = pipe.StartPosition.Distance(pipe.EndPosition); |
| | | } |
| | | if (pipe.Diameter < 0.1) |
| | | { |
| | | pipe.Diameter = 500; |
| | | } |
| | | if (pipe.Roughness < 0.1) |
| | | { |
| | | pipe.Roughness = 110; |
| | | } |
| | | 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)) |
| | | { |
| | | 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, |
| | | 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; |
| | | } |
| | | 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 = 500; |
| | | } |
| | | if (translation.Roughness < 0.1) |
| | | { |
| | | translation.Roughness = 110; |
| | | } |
| | | model.Translations.Add(translation); |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Pump: |
| | |
| | | pump.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | pump.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | pump.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var linkList = JsonHelper.Json2Object<List<RevitJsonLinkerModel>>(jobject[RevitJsonProp.Links].ToString()); |
| | | var startLinker = linkList.GetStartLinker(); |
| | | var endLinker = linkList.GetEndLinker(); |
| | | pump.StartCode = startLinker.ConnectId; |
| | | pump.EndCode = endLinker.ConnectId; |
| | | pump.StartPosition = new Model.RevitPosition() |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | pump.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | X = startLinker.Point.X, |
| | | Y = startLinker.Point.Y, |
| | | Z = startLinker.Point.Z |
| | | }; |
| | | pump.EndPosition = new Model.RevitPosition() |
| | | { |
| | | X = endLinker.Point.X, |
| | | Y = endLinker.Point.Y, |
| | | Z = endLinker.Point.Z |
| | | }; |
| | | 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.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; |
| | | } |
| | | model.Pumps.Add(pump); |
| | | } |
| | | break; |
| | |
| | | valve.ModelType = jobject[RevitJsonProp.ModelType].ToString(); |
| | | valve.Flags = Yw.Untity.FlagsHelper.ToList(jobject[RevitJsonProp.Flags].ToString()); |
| | | valve.Description = jobject[RevitJsonProp.Description].ToString(); |
| | | var linkList = JsonHelper.Json2Object<List<RevitJsonLinkerModel>>(jobject[RevitJsonProp.Links].ToString()); |
| | | var startLinker = linkList.GetStartLinker(); |
| | | var endLinker = linkList.GetEndLinker(); |
| | | valve.StartCode = startLinker.ConnectId; |
| | | valve.EndCode = endLinker.ConnectId; |
| | | valve.StartPosition = new Model.RevitPosition() |
| | | var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(jobject[RevitJsonProp.Connects].ToString()); |
| | | valve.ConnectList = connectList?.Select(x => new Model.RevitConnect() |
| | | { |
| | | X = startLinker.Point.X, |
| | | Y = startLinker.Point.Y, |
| | | Z = startLinker.Point.Z |
| | | }; |
| | | valve.EndPosition = new Model.RevitPosition() |
| | | { |
| | | X = endLinker.Point.X, |
| | | Y = endLinker.Point.Y, |
| | | Z = endLinker.Point.Z |
| | | }; |
| | | 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.MinorLoss = minorLoss; |
| | | } |
| | | |
| | | if (valve.Diameter < 0.1) |
| | | { |
| | | valve.Diameter = 500; |
| | | } |
| | | |
| | | valve.ValveType = jobject[RevitJsonProp.ValveType].ToString(); |
| | | valve.ValveSetting = jobject[RevitJsonProp.ValveSetting].ToString(); |
| | | model.Valves.Add(valve); |
| | | } |
| | | break; |
| | | |
| | | case RevitJsonCatalog.Other: |
| | | { |
| | | 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; |
| | | 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> |
| | | /// <param name="revitJsonFile">json文件路径</param> |
| | | /// <returns></returns> |
| | | 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; |