/***************************************************/ public static IBHoMObject FromRevit(this EnergyAnalysisSpace energyAnalysisSpace, Discipline discipline, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { switch (discipline) { case Discipline.Environmental: case Discipline.Architecture: case Discipline.Physical: return(energyAnalysisSpace.SpaceFromRevit(settings, refObjects)); default: return(null); } }
public static Space ToSAM(this EnergyAnalysisSpace energyAnalysisSpace, ConvertSettings convertSettings) { if (energyAnalysisSpace == null) { return(null); } Document document = energyAnalysisSpace.Document; SpatialElement spatialElement = Core.Revit.Query.Element(document, energyAnalysisSpace.CADObjectUniqueId) as SpatialElement; if (spatialElement == null) { return(null); } return(ToSAM(spatialElement, convertSettings)); }
/***************************************************/ public static IBHoMObject FromRevit(this EnergyAnalysisSpace energyAnalysisSpace, Discipline discipline, Transform transform = null, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { IElement2D result = null; switch (discipline) { case Discipline.Facade: case Discipline.Environmental: case Discipline.Architecture: case Discipline.Physical: result = energyAnalysisSpace.SpaceFromRevit(settings, refObjects); break; } if (result != null && transform?.IsIdentity == false) { TransformMatrix bHoMTransform = transform.FromRevit(); result = result.ITransform(bHoMTransform); } return(result as IBHoMObject); }
private void Stream( ArrayList data, EnergyAnalysisSpace eaSpace ) { data.Add( new Snoop.Data.ClassSeparator( typeof( EnergyAnalysisSpace ) ) ); data.Add( new Snoop.Data.Double( "Analytical Volume", eaSpace.AnalyticalVolume ) ); data.Add( new Snoop.Data.Double( "Area", eaSpace.Area ) ); data.Add( new Snoop.Data.String( "CAD Object UniqueId", eaSpace.CADObjectUniqueId ) ); data.Add( new Snoop.Data.String( "ComposedName", eaSpace.ComposedName ) ); data.Add( new Snoop.Data.String( "Description", eaSpace.Description ) ); data.Add( new Snoop.Data.Double( "InnerVolume", eaSpace.InnerVolume ) ); data.Add( new Snoop.Data.String( "SpaceName", eaSpace.SpaceName ) ); }
/***************************************************/ public static Space SpaceFromRevit(this EnergyAnalysisSpace energyAnalysisSpace, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { if (energyAnalysisSpace == null) { return(new Space()); } settings = settings.DefaultIfNull(); Space space = refObjects.GetValue <Space>(energyAnalysisSpace.Id.IntegerValue); if (space != null) { return(space); } SpatialElement spatialElement = energyAnalysisSpace.Document.Element(energyAnalysisSpace.CADObjectUniqueId) as SpatialElement; if (spatialElement == null) { return(space); //If we can't get data from it let's not waste our time } space = new Space(); space.Name = Query.Name(spatialElement); Polyline pline = energyAnalysisSpace.GetBoundary().Select(x => x.FromRevit()).ToList().Join().FirstOrDefault(); if (pline != null) { space.Location = pline.Centroid(); space.Perimeter = pline; } else if (spatialElement != null && spatialElement.Location != null) { space.Location = (spatialElement.Location as LocationPoint).FromRevit(); } //Set ExtendedProperties OriginContextFragment originContext = new OriginContextFragment() { ElementID = spatialElement.Id.IntegerValue.ToString(), TypeName = Query.Name(spatialElement) }; originContext.SetProperties(energyAnalysisSpace, settings.ParameterSettings); originContext.SetProperties(spatialElement, settings.ParameterSettings); space.AddFragment(originContext); SpaceAnalyticalFragment spaceAnalytical = new SpaceAnalyticalFragment(); spaceAnalytical.SetProperties(energyAnalysisSpace, settings.ParameterSettings); spaceAnalytical.SetProperties(spatialElement, settings.ParameterSettings); space.AddFragment(spaceAnalytical); SpaceContextFragment spaceContext = new SpaceContextFragment(); List <string> connectedElements = new List <string>(); foreach (EnergyAnalysisSurface energyAnalysisSurface in energyAnalysisSpace.GetAnalyticalSurfaces()) { connectedElements.Add(energyAnalysisSurface.CADObjectUniqueId); } spaceContext.ConnectedElements = connectedElements; spaceContext.SetProperties(energyAnalysisSpace, settings.ParameterSettings); spaceContext.SetProperties(spatialElement, settings.ParameterSettings); space.AddFragment(spaceContext); //Set identifiers, parameters & custom data space.SetIdentifiers(spatialElement); space.CopyParameters(spatialElement, settings.ParameterSettings); space.SetProperties(spatialElement, settings.ParameterSettings); space.SetProperties(energyAnalysisSpace, settings.ParameterSettings); refObjects.AddOrReplace(energyAnalysisSpace.Id, space); return(space); }
/***************************************************/ internal static oM.Environment.Elements.Panel EnvironmentPanelFromRevit(this EnergyAnalysisSurface energyAnalysisSurface, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { settings = settings.DefaultIfNull(); oM.Environment.Elements.Panel panel = refObjects.GetValue <oM.Environment.Elements.Panel>(energyAnalysisSurface.Id); if (panel != null) { return(panel); } //Get the geometry Curve ICurve curve = null; if (energyAnalysisSurface != null) { curve = energyAnalysisSurface.GetPolyloop().FromRevit(); } //Get the name and element type Element element = energyAnalysisSurface.Document.Element(energyAnalysisSurface.CADObjectUniqueId, energyAnalysisSurface.CADLinkUniqueId); ElementType elementType = null; if (element == null) { return(panel); } elementType = element.Document.GetElement(element.GetTypeId()) as ElementType; panel = new oM.Environment.Elements.Panel() { ExternalEdges = curve.ToEdges(), Name = element.FamilyTypeFullName(), }; //Set ExtendedProperties OriginContextFragment originContext = new OriginContextFragment() { ElementID = element.Id.IntegerValue.ToString(), TypeName = element.FamilyTypeFullName() }; originContext.SetProperties(element, settings.ParameterSettings); originContext.SetProperties(elementType, settings.ParameterSettings); panel.AddFragment(originContext); PanelAnalyticalFragment panelAnalytical = new PanelAnalyticalFragment(); panelAnalytical.SetProperties(elementType, settings.ParameterSettings); panelAnalytical.SetProperties(element, settings.ParameterSettings); panel.AddFragment(panelAnalytical); PanelContextFragment panelContext = new PanelContextFragment(); List <string> connectedSpaces = new List <string>(); EnergyAnalysisSpace energyAnalysisSpace = null; energyAnalysisSpace = energyAnalysisSurface.GetAnalyticalSpace(); if (energyAnalysisSpace != null) { SpatialElement spatialElement = energyAnalysisSpace.Document.Element(energyAnalysisSpace.CADObjectUniqueId) as SpatialElement; connectedSpaces.Add(Query.Name(spatialElement)); } energyAnalysisSpace = energyAnalysisSurface.GetAdjacentAnalyticalSpace(); if (energyAnalysisSpace != null) { SpatialElement spatialElement = energyAnalysisSpace.Document.Element(energyAnalysisSpace.CADObjectUniqueId) as SpatialElement; if (spatialElement != null) { connectedSpaces.Add(Query.Name(spatialElement)); if (spatialElement is Autodesk.Revit.DB.Mechanical.Space) { Autodesk.Revit.DB.Mechanical.Space space = (Autodesk.Revit.DB.Mechanical.Space)spatialElement; BuildingResultFragment buildingResultsProperties = new BuildingResultFragment(); buildingResultsProperties.PeakCooling = space.DesignCoolingLoad.ToSI(UnitType.UT_HVAC_Cooling_Load); buildingResultsProperties.PeakHeating = space.DesignHeatingLoad.ToSI(UnitType.UT_HVAC_Heating_Load); panel.AddFragment(buildingResultsProperties); } } } panel.ConnectedSpaces = connectedSpaces; panelContext.SetProperties(elementType, settings.ParameterSettings); panelContext.SetProperties(element, settings.ParameterSettings); panel.AddFragment(panelContext); oM.Environment.Elements.PanelType?panelType = element.Category.PanelType(); if (panelType.HasValue) { panel.Type = panelType.Value; } else { panel.Type = oM.Environment.Elements.PanelType.Undefined; } panel.Construction = Convert.ConstructionFromRevit(elementType as dynamic, null, settings, refObjects); //Set identifiers, parameters & custom data panel.SetIdentifiers(element); panel.CopyParameters(element, settings.ParameterSettings); panel.SetProperties(element, settings.ParameterSettings); refObjects.AddOrReplace(energyAnalysisSurface.Id, panel); return(panel); }