namespace HStation.Hydro { /// /// 转换辅助类 /// public class TransferHelper { /// /// 从Revit转换 /// public static Yw.Model.HydroModelInfo FromRevit(HStation.Model.RevitModel revitModel, out string msg) { msg = string.Empty; var hydro = new Yw.Model.HydroModelInfo(); hydro.Name = revitModel.Name; hydro.Code = null; hydro.Paras = null; hydro.Flags = null; hydro.TagName = null; hydro.Description = revitModel.Description; //水库 if (revitModel.Reservoirs != null && revitModel.Reservoirs.Count > 0) { foreach (var revitReservoir in revitModel.Reservoirs) { var reservoir = new Yw.Model.HydroReservoirInfo(); reservoir.Catalog = Yw.Hydro.ParterCatalog.Reservoir; reservoir.Name = revitReservoir.Name; reservoir.Code = revitReservoir.Code; reservoir.ModelType = revitReservoir.ModelType; reservoir.Flags = revitReservoir.Flags; reservoir.Description = revitReservoir.Description; reservoir.Quality = revitReservoir.Quality; reservoir.PoolElev = revitReservoir.PoolElev; reservoir.Head = revitReservoir.Head; reservoir.HeadPattern = revitReservoir.HeadPattern; reservoir.Position2d = new Yw.Model.Hydro.Position2d(revitReservoir.Position.X, revitReservoir.Position.Y); reservoir.Position3d = new Yw.Model.Hydro.Position3d(revitReservoir.Position.X, revitReservoir.Position.Y, revitReservoir.Position.Z); reservoir.ScenePropValueList = revitReservoir.PropValueList?.Select(x => new Yw.Model.HydroParterScenePropValuePureInfo() { Scene = HStation.Revit.ConstParas.Scene, PropName = x.PropName, PropValue = x.PropValue }).ToList(); hydro.Reservoirs.Add(reservoir); } } //水池 if (revitModel.Tanks != null && revitModel.Tanks.Count > 0) { foreach (var revitTank in revitModel.Tanks) { var tank = new Yw.Model.HydroTankInfo(); tank.Catalog = Yw.Hydro.ParterCatalog.Tank; tank.Name = revitTank.Name; tank.Code = revitTank.Code; tank.ModelType = revitTank.ModelType; tank.Flags = revitTank.Flags; tank.Description = revitTank.Description; tank.Quality = revitTank.Quality; tank.PoolElev = revitTank.PoolElev; tank.InitLevel = revitTank.InitLevel; tank.MinLevel = revitTank.MinLevel; tank.MaxLevel = revitTank.MaxLevel; tank.Diameter = revitTank.Diameter; tank.MinVol = revitTank.MinVol; tank.VolCurve = revitTank.VolCurve; tank.Position2d = new Yw.Model.Hydro.Position2d(revitTank.Position.X, revitTank.Position.Y); tank.Position3d = new Yw.Model.Hydro.Position3d(revitTank.Position.X, revitTank.Position.Y, revitTank.Position.Z); tank.ScenePropValueList = revitTank.PropValueList?.Select(x => new Yw.Model.HydroParterScenePropValuePureInfo() { Scene = HStation.Revit.ConstParas.Scene, PropName = x.PropName, PropValue = x.PropValue }).ToList(); hydro.Tanks.Add(tank); } } //水箱 if (revitModel.Waterboxs != null && revitModel.Waterboxs.Count > 0) { foreach (var revitWaterbox in revitModel.Waterboxs) { var waterbox = new Yw.Model.HydroWaterboxInfo(); waterbox.Catalog = Yw.Hydro.ParterCatalog.Waterbox; waterbox.Name = revitWaterbox.Name; waterbox.Code = revitWaterbox.Code; waterbox.ModelType = revitWaterbox.ModelType; waterbox.Flags = revitWaterbox.Flags; waterbox.Description = revitWaterbox.Description; waterbox.Quality = revitWaterbox.Quality; waterbox.PoolElev = revitWaterbox.PoolElev; waterbox.InitLevel = revitWaterbox.InitLevel; waterbox.MinLevel = revitWaterbox.MinLevel; waterbox.MaxLevel = revitWaterbox.MaxLevel; waterbox.Diameter = revitWaterbox.Diameter; waterbox.MinVol = revitWaterbox.MinVol; waterbox.VolCurve = revitWaterbox.VolCurve; waterbox.Position2d = new Yw.Model.Hydro.Position2d(revitWaterbox.Position.X, revitWaterbox.Position.Y); waterbox.Position3d = new Yw.Model.Hydro.Position3d(revitWaterbox.Position.X, revitWaterbox.Position.Y, revitWaterbox.Position.Z); waterbox.ScenePropValueList = revitWaterbox.PropValueList?.Select(x => new Yw.Model.HydroParterScenePropValuePureInfo() { Scene = HStation.Revit.ConstParas.Scene, PropName = x.PropName, PropValue = x.PropValue }).ToList(); hydro.Waterboxs.Add(waterbox); } } //连接节点 if (revitModel.Junctions != null && revitModel.Junctions.Count > 0) { foreach (var revitJunction in revitModel.Junctions) { var junction = new Yw.Model.HydroJunctionInfo(); junction.Catalog = Yw.Hydro.ParterCatalog.Junction; junction.Name = revitJunction.Name; junction.Code = revitJunction.Code; junction.ModelType = revitJunction.ModelType; junction.Flags = revitJunction.Flags; junction.Description = revitJunction.Description; junction.Quality = revitJunction.Quality; junction.Elev = revitJunction.Elev; junction.Demand = revitJunction.Demand; junction.DemandPattern = revitJunction.DemandPattern; junction.Position2d = new Yw.Model.Hydro.Position2d(revitJunction.Position.X, revitJunction.Position.Y); junction.Position3d = new Yw.Model.Hydro.Position3d(revitJunction.Position.X, revitJunction.Position.Y, revitJunction.Position.Z); junction.ScenePropValueList = revitJunction.PropValueList?.Select(x => new Yw.Model.HydroParterScenePropValuePureInfo() { Scene = HStation.Revit.ConstParas.Scene, PropName = x.PropName, PropValue = x.PropValue }).ToList(); hydro.Junctions.Add(junction); } } //弯头 if (revitModel.Elbows != null && revitModel.Elbows.Count > 0) { foreach (var revitElbow in revitModel.Elbows) { var elbow = new Yw.Model.HydroElbowInfo(); elbow.Catalog = Yw.Hydro.ParterCatalog.Elbow; elbow.Name = revitElbow.Name; elbow.Code = revitElbow.Code; elbow.ModelType = revitElbow.ModelType; elbow.Flags = revitElbow.Flags; elbow.Description = revitElbow.Description; elbow.Quality = revitElbow.Quality; elbow.Elev = revitElbow.Elev; elbow.Demand = revitElbow.Demand; elbow.DemandPattern = revitElbow.DemandPattern; elbow.Position2d = new Yw.Model.Hydro.Position2d(revitElbow.Position.X, revitElbow.Position.Y); elbow.Position3d = new Yw.Model.Hydro.Position3d(revitElbow.Position.X, revitElbow.Position.Y, revitElbow.Position.Z); elbow.ScenePropValueList = revitElbow.PropValueList?.Select(x => new Yw.Model.HydroParterScenePropValuePureInfo() { Scene = HStation.Revit.ConstParas.Scene, PropName = x.PropName, PropValue = x.PropValue }).ToList(); hydro.Elbows.Add(elbow); } } //三通 if (revitModel.Threelinks != null && revitModel.Threelinks.Count > 0) { foreach (var revitThreelink in revitModel.Threelinks) { var threelink = new Yw.Model.HydroThreelinkInfo(); threelink.Catalog = Yw.Hydro.ParterCatalog.Threelink; threelink.Name = revitThreelink.Name; threelink.Code = revitThreelink.Code; threelink.ModelType = revitThreelink.ModelType; threelink.Flags = revitThreelink.Flags; threelink.Description = revitThreelink.Description; threelink.Quality = revitThreelink.Quality; threelink.Elev = revitThreelink.Elev; threelink.Demand = revitThreelink.Demand; threelink.DemandPattern = revitThreelink.DemandPattern; threelink.Position2d = new Yw.Model.Hydro.Position2d(revitThreelink.Position.X, revitThreelink.Position.Y); threelink.Position3d = new Yw.Model.Hydro.Position3d(revitThreelink.Position.X, revitThreelink.Position.Y, revitThreelink.Position.Z); threelink.ScenePropValueList = revitThreelink.PropValueList?.Select(x => new Yw.Model.HydroParterScenePropValuePureInfo() { Scene = HStation.Revit.ConstParas.Scene, PropName = x.PropName, PropValue = x.PropValue }).ToList(); hydro.Threelinks.Add(threelink); } } //四通 if (revitModel.Fourlinks != null && revitModel.Fourlinks.Count > 0) { foreach (var revitFourlink in revitModel.Fourlinks) { var fourlink = new Yw.Model.HydroFourlinkInfo(); fourlink.Catalog = Yw.Hydro.ParterCatalog.Fourlink; fourlink.Name = revitFourlink.Name; fourlink.Code = revitFourlink.Code; fourlink.ModelType = revitFourlink.ModelType; fourlink.Flags = revitFourlink.Flags; fourlink.Description = revitFourlink.Description; fourlink.Quality = revitFourlink.Quality; fourlink.Elev = revitFourlink.Elev; fourlink.Demand = revitFourlink.Demand; fourlink.DemandPattern = revitFourlink.DemandPattern; fourlink.Position2d = new Yw.Model.Hydro.Position2d(revitFourlink.Position.X, revitFourlink.Position.Y); fourlink.Position3d = new Yw.Model.Hydro.Position3d(revitFourlink.Position.X, revitFourlink.Position.Y, revitFourlink.Position.Z); fourlink.ScenePropValueList = revitFourlink.PropValueList?.Select(x => new Yw.Model.HydroParterScenePropValuePureInfo() { Scene = HStation.Revit.ConstParas.Scene, PropName = x.PropName, PropValue = x.PropValue }).ToList(); hydro.Fourlinks.Add(fourlink); } } //喷嘴 if (revitModel.Nozzles != null && revitModel.Nozzles.Count > 0) { foreach (var revitNozzle in revitModel.Nozzles) { var nozzle = new Yw.Model.HydroNozzleInfo(); nozzle.Catalog = Yw.Hydro.ParterCatalog.Nozzle; nozzle.Name = revitNozzle.Name; nozzle.Code = revitNozzle.Code; nozzle.ModelType = revitNozzle.ModelType; nozzle.Flags = revitNozzle.Flags; nozzle.Description = revitNozzle.Description; nozzle.Quality = revitNozzle.Quality; nozzle.Coefficient = revitNozzle.Coefficient; nozzle.Elev = revitNozzle.Elev; nozzle.Demand = revitNozzle.Demand; nozzle.DemandPattern = revitNozzle.DemandPattern; nozzle.Position2d = new Yw.Model.Hydro.Position2d(revitNozzle.Position.X, revitNozzle.Position.Y); nozzle.Position3d = new Yw.Model.Hydro.Position3d(revitNozzle.Position.X, revitNozzle.Position.Y, revitNozzle.Position.Z); nozzle.ScenePropValueList = revitNozzle.PropValueList?.Select(x => new Yw.Model.HydroParterScenePropValuePureInfo() { Scene = HStation.Revit.ConstParas.Scene, PropName = x.PropName, PropValue = x.PropValue }).ToList(); hydro.Nozzles.Add(nozzle); } } //消火栓 if (revitModel.Hydrants != null && revitModel.Hydrants.Count > 0) { foreach (var revitHydrant in revitModel.Hydrants) { var hydrant = new Yw.Model.HydroHydrantInfo(); hydrant.Catalog = Yw.Hydro.ParterCatalog.Hydrant; hydrant.Name = revitHydrant.Name; hydrant.Code = revitHydrant.Code; hydrant.ModelType = revitHydrant.ModelType; hydrant.Flags = revitHydrant.Flags; hydrant.Description = revitHydrant.Description; hydrant.Quality = revitHydrant.Quality; hydrant.Coefficient = revitHydrant.Coefficient; hydrant.Elev = revitHydrant.Elev; hydrant.Demand = revitHydrant.Demand; hydrant.DemandPattern = revitHydrant.DemandPattern; hydrant.Position2d = new Yw.Model.Hydro.Position2d(revitHydrant.Position.X, revitHydrant.Position.Y); hydrant.Position3d = new Yw.Model.Hydro.Position3d(revitHydrant.Position.X, revitHydrant.Position.Y, revitHydrant.Position.Z); hydrant.ScenePropValueList = revitHydrant.PropValueList?.Select(x => new Yw.Model.HydroParterScenePropValuePureInfo() { Scene = HStation.Revit.ConstParas.Scene, PropName = x.PropName, PropValue = x.PropValue }).ToList(); hydro.Hydrants.Add(hydrant); } } //水表 if (revitModel.Meters != null && revitModel.Meters.Count > 0) { foreach (var revitMeter in revitModel.Meters) { var meter = new Yw.Model.HydroMeterInfo(); meter.Catalog = Yw.Hydro.ParterCatalog.Meter; meter.Name = revitMeter.Name; meter.Code = revitMeter.Code; meter.ModelType = revitMeter.ModelType; meter.Flags = revitMeter.Flags; meter.Description = revitMeter.Description; meter.Quality = revitMeter.Quality; meter.Elev = revitMeter.Elev; meter.Demand = revitMeter.Demand; meter.DemandPattern = revitMeter.DemandPattern; meter.Position2d = new Yw.Model.Hydro.Position2d(revitMeter.Position.X, revitMeter.Position.Y); meter.Position3d = new Yw.Model.Hydro.Position3d(revitMeter.Position.X, revitMeter.Position.Y, revitMeter.Position.Z); meter.ScenePropValueList = revitMeter.PropValueList?.Select(x => new Yw.Model.HydroParterScenePropValuePureInfo() { Scene = HStation.Revit.ConstParas.Scene, PropName = x.PropName, PropValue = x.PropValue }).ToList(); hydro.Meters.Add(meter); } } //流量计 if (revitModel.Flowmeters != null && revitModel.Flowmeters.Count > 0) { foreach (var revitFlowmeter in revitModel.Flowmeters) { var flowmeter = new Yw.Model.HydroFlowmeterInfo(); flowmeter.Catalog = Yw.Hydro.ParterCatalog.Flowmeter; flowmeter.Name = revitFlowmeter.Name; flowmeter.Code = revitFlowmeter.Code; flowmeter.ModelType = revitFlowmeter.ModelType; flowmeter.Flags = revitFlowmeter.Flags; flowmeter.Description = revitFlowmeter.Description; flowmeter.Quality = revitFlowmeter.Quality; flowmeter.Elev = revitFlowmeter.Elev; flowmeter.Demand = revitFlowmeter.Demand; flowmeter.DemandPattern = revitFlowmeter.DemandPattern; flowmeter.Position2d = new Yw.Model.Hydro.Position2d(revitFlowmeter.Position.X, revitFlowmeter.Position.Y); flowmeter.Position3d = new Yw.Model.Hydro.Position3d(revitFlowmeter.Position.X, revitFlowmeter.Position.Y, revitFlowmeter.Position.Z); flowmeter.ScenePropValueList = revitFlowmeter.PropValueList?.Select(x => new Yw.Model.HydroParterScenePropValuePureInfo() { Scene = HStation.Revit.ConstParas.Scene, PropName = x.PropName, PropValue = x.PropValue }).ToList(); hydro.Flowmeters.Add(flowmeter); } } //压力表 if (revitModel.Pressmeters != null && revitModel.Pressmeters.Count > 0) { foreach (var revitPressmeter in revitModel.Pressmeters) { var pressmeter = new Yw.Model.HydroPressmeterInfo(); pressmeter.Catalog = Yw.Hydro.ParterCatalog.Pressmeter; pressmeter.Name = revitPressmeter.Name; pressmeter.Code = revitPressmeter.Code; pressmeter.ModelType = revitPressmeter.ModelType; pressmeter.Flags = revitPressmeter.Flags; pressmeter.Description = revitPressmeter.Description; pressmeter.Quality = revitPressmeter.Quality; pressmeter.Elev = revitPressmeter.Elev; pressmeter.Demand = revitPressmeter.Demand; pressmeter.DemandPattern = revitPressmeter.DemandPattern; pressmeter.Position2d = new Yw.Model.Hydro.Position2d(revitPressmeter.Position.X, revitPressmeter.Position.Y); pressmeter.Position3d = new Yw.Model.Hydro.Position3d(revitPressmeter.Position.X, revitPressmeter.Position.Y, revitPressmeter.Position.Z); pressmeter.ScenePropValueList = revitPressmeter.PropValueList?.Select(x => new Yw.Model.HydroParterScenePropValuePureInfo() { Scene = HStation.Revit.ConstParas.Scene, PropName = x.PropName, PropValue = x.PropValue }).ToList(); hydro.Pressmeters.Add(pressmeter); } } //闷头 if (revitModel.Bluntheads != null && revitModel.Bluntheads.Count > 0) { foreach (var revitBlunthead in revitModel.Bluntheads) { var blunthead = new Yw.Model.HydroBluntheadInfo(); blunthead.Catalog = Yw.Hydro.ParterCatalog.Blunthead; blunthead.Name = revitBlunthead.Name; blunthead.Code = revitBlunthead.Code; blunthead.ModelType = revitBlunthead.ModelType; blunthead.Flags = revitBlunthead.Flags; blunthead.Description = revitBlunthead.Description; blunthead.Quality = revitBlunthead.Quality; blunthead.Elev = revitBlunthead.Elev; blunthead.Demand = revitBlunthead.Demand; blunthead.DemandPattern = revitBlunthead.DemandPattern; blunthead.Position2d = new Yw.Model.Hydro.Position2d(revitBlunthead.Position.X, revitBlunthead.Position.Y); blunthead.Position3d = new Yw.Model.Hydro.Position3d(revitBlunthead.Position.X, revitBlunthead.Position.Y, revitBlunthead.Position.Z); blunthead.ScenePropValueList = revitBlunthead.PropValueList?.Select(x => new Yw.Model.HydroParterScenePropValuePureInfo() { Scene = HStation.Revit.ConstParas.Scene, PropName = x.PropName, PropValue = x.PropValue }).ToList(); hydro.Bluntheads.Add(blunthead); } } //水泵 if (revitModel.Pumps != null && revitModel.Pumps.Count > 0) { foreach (var revitPump in revitModel.Pumps) { var pump = new Yw.Model.HydroPumpInfo(); pump.Catalog = Yw.Hydro.ParterCatalog.Pump; pump.Name = revitPump.Name; pump.Code = revitPump.Code; pump.ModelType = revitPump.ModelType; pump.Flags = revitPump.Flags; pump.Description = revitPump.Description; pump.StartCode = revitPump.StartCode; pump.EndCode = revitPump.EndCode; pump.LinkStatus = revitPump.LinkStatus; pump.RatedPower = revitPump.RatedPower; pump.CurveQH = revitPump.CurveQH; pump.Price = revitPump.Price; pump.PricePattern = revitPump.PricePattern; pump.CurveQE = revitPump.CurveQE; pump.ScenePropValueList = revitPump.PropValueList?.Select(x => new Yw.Model.HydroParterScenePropValuePureInfo() { Scene = HStation.Revit.ConstParas.Scene, PropName = x.PropName, PropValue = x.PropValue }).ToList(); hydro.Pumps.Add(pump); } } //阀门 if (revitModel.Valves != null && revitModel.Valves.Count > 0) { foreach (var revitValve in revitModel.Valves) { var valve = new Yw.Model.HydroValveInfo(); valve.Catalog = Yw.Hydro.ParterCatalog.Valve; valve.Name = revitValve.Name; valve.Code = revitValve.Code; valve.ModelType = revitValve.ModelType; valve.Flags = revitValve.Flags; valve.Description = revitValve.Description; valve.StartCode = revitValve.StartCode; valve.EndCode = revitValve.EndCode; valve.LinkStatus = revitValve.LinkStatus; valve.Diameter = revitValve.Diameter; valve.MinorLoss = revitValve.MinorLoss; valve.ValveType = revitValve.ValveType; valve.ValveSetting = revitValve.ValveSetting; valve.ScenePropValueList = revitValve.PropValueList?.Select(x => new Yw.Model.HydroParterScenePropValuePureInfo() { Scene = HStation.Revit.ConstParas.Scene, PropName = x.PropName, PropValue = x.PropValue }).ToList(); hydro.Valves.Add(valve); } } //管道 if (revitModel.Pipes != null && revitModel.Pipes.Count > 0) { foreach (var revitPipe in revitModel.Pipes) { var pipe = new Yw.Model.HydroPipeInfo(); pipe.Catalog = Yw.Hydro.ParterCatalog.Pipe; pipe.Name = revitPipe.Name; pipe.Code = revitPipe.Code; pipe.ModelType = revitPipe.ModelType; pipe.Flags = revitPipe.Flags; pipe.Description = revitPipe.Description; pipe.StartCode = revitPipe.StartCode; pipe.EndCode = revitPipe.EndCode; pipe.LinkStatus = revitPipe.LinkStatus; pipe.Diameter = revitPipe.Diameter; pipe.Length = revitPipe.Length; pipe.Roughness = revitPipe.Roughness; pipe.MinorLoss = revitPipe.MinorLoss; pipe.ScenePropValueList = revitPipe.PropValueList?.Select(x => new Yw.Model.HydroParterScenePropValuePureInfo() { Scene = HStation.Revit.ConstParas.Scene, PropName = x.PropName, PropValue = x.PropValue }).ToList(); hydro.Pipes.Add(pipe); } } //过渡件 if (revitModel.Translations != null && revitModel.Translations.Count > 0) { foreach (var revitTranslation in revitModel.Translations) { var translation = new Yw.Model.HydroPipeInfo(); translation.Catalog = Yw.Hydro.ParterCatalog.Translation; translation.Name = revitTranslation.Name; translation.Code = revitTranslation.Code; translation.ModelType = revitTranslation.ModelType; translation.Flags = revitTranslation.Flags; translation.Description = revitTranslation.Description; translation.StartCode = revitTranslation.StartCode; translation.EndCode = revitTranslation.EndCode; translation.LinkStatus = revitTranslation.LinkStatus; translation.Diameter = revitTranslation.Diameter; translation.Length = revitTranslation.Length; translation.Roughness = revitTranslation.Roughness; translation.MinorLoss = revitTranslation.MinorLoss; translation.ScenePropValueList = revitTranslation.PropValueList?.Select(x => new Yw.Model.HydroParterScenePropValuePureInfo() { Scene = HStation.Revit.ConstParas.Scene, PropName = x.PropName, PropValue = x.PropValue }).ToList(); hydro.Pipes.Add(translation); } } //换热器 if (revitModel.Exchangers != null && revitModel.Exchangers.Count > 0) { foreach (var revitExchanger in revitModel.Exchangers) { var exchanger = new Yw.Model.HydroExchangerInfo(); exchanger.Catalog = Yw.Hydro.ParterCatalog.Exchanger; exchanger.Name = revitExchanger.Name; exchanger.Code = revitExchanger.Code; exchanger.ModelType = revitExchanger.ModelType; exchanger.Flags = revitExchanger.Flags; exchanger.Description = revitExchanger.Description; exchanger.StartCode = revitExchanger.StartCode; exchanger.EndCode = revitExchanger.EndCode; exchanger.LinkStatus = revitExchanger.LinkStatus; exchanger.Diameter = revitExchanger.Diameter; exchanger.Length = revitExchanger.Length; exchanger.Roughness = revitExchanger.Roughness; exchanger.MinorLoss = revitExchanger.MinorLoss; exchanger.ScenePropValueList = revitExchanger.PropValueList?.Select(x => new Yw.Model.HydroParterScenePropValuePureInfo() { Scene = HStation.Revit.ConstParas.Scene, PropName = x.PropName, PropValue = x.PropValue }).ToList(); hydro.Exchangers.Add(exchanger); } } //装饰件 if (revitModel.Decorators != null && revitModel.Decorators.Count > 0) { hydro.Decorators = new List(); foreach (var revitDecorator in revitModel.Decorators) { var decorator = new Yw.Model.HydroDecoratorInfo(); decorator.Scene = HStation.Revit.ConstParas.Scene; decorator.Name = revitDecorator.Name; decorator.Category = revitDecorator.Category; decorator.Decoration = revitDecorator.Decoration; decorator.Description = revitDecorator.Description; hydro.Decorators.Add(decorator); } } return hydro; } } }