public static Construction ToSAM_Construction(this RevitType3D revitType3D) { if (revitType3D == null) { return(null); } Construction result = new Construction(revitType3D.Guid, revitType3D.Name); List <Core.ParameterSet> parameterSets = revitType3D.GetParamaterSets(); if (parameterSets != null) { foreach (Core.ParameterSet parameterSet in parameterSets) { result.Add(parameterSet); } } return(result); }
public static AnalyticalModel UpdateT3D(this AnalyticalModel analyticalModel, T3DDocument t3DDocument) { if (analyticalModel == null) { return(null); } Building building = t3DDocument?.Building; if (building == null) { return(null); } Modify.RemoveUnsusedZones(building); double northAngle = double.NaN; if (analyticalModel.TryGetValue(AnalyticalModelParameter.NorthAngle, out northAngle)) { building.northAngle = global::System.Math.Round(Units.Convert.ToDegrees(northAngle), 1); } Location location = analyticalModel.Location; if (location != null) { building.longitude = location.Longitude; building.latitude = location.Latitude; if (location.TryGetValue(LocationParameter.TimeZone, out string timeZone)) { double @double = Core.Query.Double(Core.Query.UTC(timeZone)); if (!double.IsNaN(@double)) { building.timeZone = global::System.Convert.ToSingle(@double); } } } AdjacencyCluster adjacencyCluster = analyticalModel?.AdjacencyCluster; if (adjacencyCluster != null) { //Zones -> Spaces Dictionary <string, Space> spaces = adjacencyCluster.SpaceDictionary(); if (spaces != null) { Dictionary <string, TAS3D.Zone> zones = building.ZoneDictionary(); if (zones != null) { foreach (KeyValuePair <string, TAS3D.Zone> keyValuePair in zones) { Space space; if (!spaces.TryGetValue(keyValuePair.Key, out space)) { continue; } if (space == null) { continue; } //TODO: Update Zone Space space_New = space.Clone(); space_New.Add(Create.ParameterSet(ActiveSetting.Setting, keyValuePair.Value)); adjacencyCluster.AddObject(space_New); } } } //Elements -> Constructions List <Construction> constructions = adjacencyCluster.GetConstructions(); if (constructions != null) { List <Element> elements = building.Elements(); if (elements != null) { foreach (Element element in elements) { Construction construction = element.Match(constructions); if (construction == null) { continue; } //Update Element //Thickness double thickness = construction.GetValue <double>(ConstructionParameter.DefaultThickness); if (double.IsNaN(thickness) || thickness == 0) { thickness = construction.GetThickness(); } if (!double.IsNaN(thickness)) { element.width = thickness; } //if (Core.Query.TryGetValue(construction, Analytical.Query.ParameterName_Thickness(), out thickness, true)) // element.width= thickness; //Colour System.Drawing.Color color = global::System.Drawing.Color.Empty; if (construction.TryGetValue(ConstructionParameter.Color, out color)) { element.colour = Core.Convert.ToUint(color); } //Transparent bool transparent = false; MaterialType materialType = Analytical.Query.MaterialType(construction.ConstructionLayers, analyticalModel.MaterialLibrary); if (materialType == MaterialType.Undefined) { materialType = MaterialType.Opaque; if (construction.TryGetValue(ConstructionParameter.Transparent, out transparent)) { element.transparent = transparent; } } else { element.transparent = materialType == MaterialType.Transparent; } //InternalShadows bool internalShadows = false; if (construction.TryGetValue(ConstructionParameter.IsInternalShadow, out internalShadows)) { element.internalShadows = internalShadows; } else { element.internalShadows = element.transparent; } //BEType string string_BEType = null; PanelType panelType = construction.PanelType(); if (panelType != Analytical.PanelType.Undefined) { string_BEType = panelType.Text(); } else { if (!construction.TryGetValue(ConstructionParameter.DefaultPanelType, out string_BEType)) { string_BEType = null; } } if (!string.IsNullOrEmpty(string_BEType)) { int bEType = BEType(string_BEType); if (bEType != -1) { element.BEType = bEType; panelType = PanelType(bEType); } } else { panelType = Analytical.PanelType.Undefined; List <Panel> panels_Construction = adjacencyCluster.GetPanels(construction); if (panels_Construction != null && panels_Construction.Count > 0) { Panel panel = panels_Construction.Find(x => x.PanelType != Analytical.PanelType.Undefined); if (panel != null) { panelType = panel.PanelType; } } } if (panelType == Analytical.PanelType.Undefined) { List <Panel> panels_Construction = adjacencyCluster.GetPanels(construction); if (panels_Construction != null && panels_Construction.Count != 0) { element.zoneFloorArea = panels_Construction.Find(x => x.PanelType.PanelGroup() == PanelGroup.Floor) != null; } } if (panelType.PanelGroup() == PanelGroup.Floor) { element.zoneFloorArea = true; } //Ground bool ground = false; if (construction.TryGetValue(ConstructionParameter.IsGround, out ground)) { element.ground = ground; } //Air bool air = false; if (construction.TryGetValue(ConstructionParameter.IsAir, out air)) { element.ghost = air; } List <Panel> panels = adjacencyCluster.GetPanels(construction); if (panels != null && panels.Count > 0) { ParameterSet parameterSet = Create.ParameterSet(ActiveSetting.Setting, element); construction.Add(parameterSet); foreach (Panel panel in panels) { Panel panel_New = Analytical.Create.Panel(panel, construction); adjacencyCluster.AddObject(panel_New); } } } } } //Windows -> ApertureConstruction List <ApertureConstruction> apertureConstructions = adjacencyCluster.GetApertureConstructions(); if (apertureConstructions != null) { List <window> windows = building.Windows(); if (windows != null) { foreach (window window in windows) { if (window == null) { continue; } ApertureConstruction apertureConstruction = window.Match(apertureConstructions); if (apertureConstruction == null) { continue; } //Colour System.Drawing.Color color = global::System.Drawing.Color.Empty; if (!apertureConstruction.TryGetValue(ApertureConstructionParameter.Color, out color)) { color = Analytical.Query.Color(apertureConstruction.ApertureType); } if (color != global::System.Drawing.Color.Empty) { window.colour = Core.Convert.ToUint(color); } //Transparent List <ConstructionLayer> constructionLayers = null; if (true) { constructionLayers = apertureConstruction.PaneConstructionLayers; } else { constructionLayers = apertureConstruction.FrameConstructionLayers; } window.transparent = false; //Requested by Michal 2021.03.01 bool transparent = false; MaterialType materialType = Analytical.Query.MaterialType(constructionLayers, analyticalModel.MaterialLibrary); if (materialType == MaterialType.Undefined) { materialType = MaterialType.Opaque; if (apertureConstruction.TryGetValue(ApertureConstructionParameter.Transparent, out transparent)) { window.transparent = transparent; } } else { window.transparent = materialType == MaterialType.Transparent; } if (window.transparent) { //InternalShadows window.internalShadows = false; //Requested by Michal 2021.03.01 bool internalShadows = false; if (apertureConstruction.TryGetValue(ApertureConstructionParameter.IsInternalShadow, out internalShadows)) { window.internalShadows = internalShadows; } else { List <Panel> panels = adjacencyCluster.GetPanels(apertureConstruction); if (panels != null && panels.Count != 0) { window.internalShadows = panels.TrueForAll(x => adjacencyCluster.External(x)); } } } //FrameWidth double frameWidth = double.NaN; if (apertureConstruction.TryGetValue(ApertureConstructionParameter.DefaultFrameWidth, out frameWidth)) { window.frameWidth = frameWidth; } } } } } AnalyticalModel result = new AnalyticalModel(analyticalModel, adjacencyCluster); return(result); }