Ejemplo n.º 1
0
        /***************************************************/
        /****              Public methods               ****/
        /***************************************************/

        public static oM.Physical.Constructions.Construction Construction(this EnergyAnalysisOpening energyAnalysisOpening, RevitSettings settings = null)
        {
            if (energyAnalysisOpening == null)
            {
                return(null);
            }

            Element element = energyAnalysisOpening.Element();

            if (element == null)
            {
                return(null);
            }

            return(element.EnergyAnalysisElementName().Construction(energyAnalysisOpening.OpeningType.ToString()));
        }
Ejemplo n.º 2
0
        /***************************************************/
        /****               Public Methods              ****/
        /***************************************************/

        public static oM.Environment.Elements.Opening OpeningFromRevit(this EnergyAnalysisOpening energyAnalysisOpening, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            settings = settings.DefaultIfNull();

            Element element = energyAnalysisOpening.Element();

            if (element == null)
            {
                oM.Environment.Elements.Opening result = refObjects.GetValue <oM.Environment.Elements.Opening>(energyAnalysisOpening.Id);
                if (result != null)
                {
                    return(result);
                }

                ICurve curve = energyAnalysisOpening.GetPolyloop().FromRevit();
                result = new oM.Environment.Elements.Opening()
                {
                    Edges = curve.ToEdges(),
                };

                OriginContextFragment originContext = new OriginContextFragment()
                {
                    ElementID = energyAnalysisOpening.Id.IntegerValue.ToString(), TypeName = energyAnalysisOpening.OpeningName
                };
                originContext.SetProperties(energyAnalysisOpening, settings.ParameterSettings);
                result.AddFragment(originContext);

                result.OpeningConstruction = energyAnalysisOpening.Construction(settings);
                result.Type = OpeningType.Undefined;

                //Set identifiers, parameters & custom data
                result.SetIdentifiers(energyAnalysisOpening);
                result.CopyParameters(energyAnalysisOpening, settings.ParameterSettings);
                result.SetProperties(energyAnalysisOpening, settings.ParameterSettings);

                refObjects.AddOrReplace(energyAnalysisOpening.Id, result);
                return(result);
            }
            else
            {
                oM.Environment.Elements.Opening result = refObjects.GetValue <oM.Environment.Elements.Opening>(energyAnalysisOpening.Id.IntegerValue);
                if (result != null)
                {
                    return(result);
                }

                ElementType elementType = element.Document.GetElement(element.GetTypeId()) as ElementType;

                ICurve curve = energyAnalysisOpening.GetPolyloop().FromRevit();
                result = new oM.Environment.Elements.Opening()
                {
                    Edges = curve.ToEdges(),
                    Name  = element.FamilyTypeFullName(),
                };

                OriginContextFragment originContext = new OriginContextFragment()
                {
                    ElementID = element.Id.IntegerValue.ToString(), TypeName = element.FamilyTypeFullName()
                };
                originContext.SetProperties(element, settings.ParameterSettings);
                originContext.SetProperties(elementType, settings.ParameterSettings);
                result.AddFragment(originContext);

                result.OpeningConstruction = energyAnalysisOpening.Construction(settings);

                OpeningType?openingType = element.Category.OpeningType();
                if (openingType.HasValue)
                {
                    result.Type = openingType.Value;
                }
                else
                {
                    result.Type = OpeningType.Undefined;
                }

                //Set identifiers, parameters & custom data
                result.SetIdentifiers(element);
                result.CopyParameters(element, settings.ParameterSettings);
                result.SetProperties(element, settings.ParameterSettings);

                refObjects.AddOrReplace(energyAnalysisOpening.Id, result);
                return(result);
            }
        }