Ejemplo n.º 1
0
        /// <summary>
        /// Processes IfcElement attributes.
        /// </summary>
        /// <param name="ifcElement">The IfcElement handle.</param>
        protected override void Process(IFCAnyHandle ifcElement)
        {
            base.Process(ifcElement);

            m_Tag = IFCAnyHandleUtil.GetStringAttribute(ifcElement, "Tag");

            ICollection <IFCAnyHandle> hasOpenings = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcElement, "HasOpenings");

            if (hasOpenings != null)
            {
                foreach (IFCAnyHandle hasOpening in hasOpenings)
                {
                    IFCAnyHandle relatedOpeningElement = IFCAnyHandleUtil.GetInstanceAttribute(hasOpening, "RelatedOpeningElement");
                    if (IFCAnyHandleUtil.IsNullOrHasNoValue(relatedOpeningElement))
                    {
                        continue;
                    }

                    IFCFeatureElementSubtraction opening = IFCFeatureElementSubtraction.ProcessIFCFeatureElementSubtraction(relatedOpeningElement);
                    if (opening != null)
                    {
                        opening.VoidsElement = this;
                        Openings.Add(opening);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Cleans out the IFCEntity to save memory.
        /// </summary>
        public override void CleanEntity()
        {
            base.CleanEntity();

            m_Tag = null;

            m_Openings = null;

            m_FillsOpening = null;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Processes IfcElement attributes.
        /// </summary>
        /// <param name="ifcElement">The IfcElement handle.</param>
        protected override void Process(IFCAnyHandle ifcElement)
        {
            base.Process(ifcElement);

            m_Tag = IFCAnyHandleUtil.GetStringAttribute(ifcElement, "Tag");

            ICollection <IFCAnyHandle> hasOpenings = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcElement, "HasOpenings");

            if (hasOpenings != null)
            {
                foreach (IFCAnyHandle hasOpening in hasOpenings)
                {
                    IFCAnyHandle relatedOpeningElement = IFCAnyHandleUtil.GetInstanceAttribute(hasOpening, "RelatedOpeningElement");
                    if (IFCAnyHandleUtil.IsNullOrHasNoValue(relatedOpeningElement))
                    {
                        continue;
                    }

                    IFCFeatureElementSubtraction opening = IFCFeatureElementSubtraction.ProcessIFCFeatureElementSubtraction(relatedOpeningElement);
                    if (opening != null)
                    {
                        opening.VoidsElement = this;
                        Openings.Add(opening);
                    }
                }
            }

            // "HasPorts" is new to IFC2x2.
            // For IFC4, "HasPorts" has moved to IfcDistributionElement.  We'll keep the check here, but we will only check it
            // if we are exporting before IFC4 or if we have an IfcDistributionElement handle.
            bool checkPorts = (IFCImportFile.TheFile.SchemaVersion > IFCSchemaVersion.IFC2x2) &&
                              (IFCImportFile.TheFile.SchemaVersion < IFCSchemaVersion.IFC4 || IFCAnyHandleUtil.IsSubTypeOf(ifcElement, IFCEntityType.IfcDistributionElement));

            if (checkPorts)
            {
                ICollection <IFCAnyHandle> hasPorts = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcElement, "HasPorts");
                if (hasPorts != null)
                {
                    foreach (IFCAnyHandle hasPort in hasPorts)
                    {
                        IFCAnyHandle relatingPort = IFCAnyHandleUtil.GetInstanceAttribute(hasPort, "RelatingPort");
                        if (IFCAnyHandleUtil.IsNullOrHasNoValue(relatingPort))
                        {
                            continue;
                        }

                        IFCPort port = IFCPort.ProcessIFCPort(relatingPort);
                        if (port != null)
                        {
                            Ports.Add(port);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates or populates Revit element params based on the information contained in this class.
        /// </summary>
        /// <param name="doc">The document.</param>
        /// <param name="element">The element.</param>
        protected override void CreateParametersInternal(Document doc, Element element)
        {
            base.CreateParametersInternal(doc, element);

            if (element != null)
            {
                Category category = IFCPropertySet.GetCategoryForParameterIfValid(element, Id);

                // Set "Tag" parameter.
                string ifcTag = Tag;
                if (!string.IsNullOrWhiteSpace(ifcTag))
                {
                    IFCPropertySet.AddParameterString(doc, element, category, "IfcTag", ifcTag, Id);
                }

                IFCFeatureElementSubtraction ifcFeatureElementSubtraction = FillsOpening;
                if (ifcFeatureElementSubtraction != null)
                {
                    IFCElement ifcElement = ifcFeatureElementSubtraction.VoidsElement;
                    if (ifcElement != null)
                    {
                        string ifcContainerName = ifcElement.Name;
                        IFCPropertySet.AddParameterString(doc, element, category, "IfcContainedInHost", ifcContainerName, Id);
                    }
                }

                // Create two parameters for each port: one for name, and one for GUID.
                // Note that Ports will never be null, as it is initialized the first time it is accessed.
                int numPorts = 0;
                foreach (IFCPort port in Ports)
                {
                    string name = port.Name;
                    string guid = port.GlobalId;

                    if (!string.IsNullOrWhiteSpace(name))
                    {
                        string parameterName = "IfcElement HasPorts Name " + ((numPorts == 0) ? "" : (numPorts + 1).ToString());
                        IFCPropertySet.AddParameterString(doc, element, category, parameterName, name, Id);
                    }

                    if (!string.IsNullOrWhiteSpace(guid))
                    {
                        string parameterName = "IfcElement HasPorts IfcGUID " + ((numPorts == 0) ? "" : (numPorts + 1).ToString());
                        IFCPropertySet.AddParameterString(doc, element, category, parameterName, guid, Id);
                    }

                    numPorts++;
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Processes an IfcFeatureElement object.
        /// </summary>
        /// <param name="ifcFeatureElement">The IfcFeatureElement handle.</param>
        /// <returns>The IFCFeatureElement object.</returns>
        public static IFCFeatureElement ProcessIFCFeatureElement(IFCAnyHandle ifcFeatureElement)
        {
            if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcFeatureElement))
            {
                Importer.TheLog.LogNullError(IFCEntityType.IfcFeatureElement);
                return(null);
            }

            IFCEntity cachedFeatureElement;

            if (IFCImportFile.TheFile.EntityMap.TryGetValue(ifcFeatureElement.StepId, out cachedFeatureElement))
            {
                return(cachedFeatureElement as IFCFeatureElement);
            }

            if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcFeatureElement, IFCEntityType.IfcFeatureElementSubtraction))
            {
                return(IFCFeatureElementSubtraction.ProcessIFCFeatureElementSubtraction(ifcFeatureElement));
            }

            return(new IFCFeatureElement(ifcFeatureElement));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Cleans out the IFCEntity to save memory.
        /// </summary>
        public override void CleanEntity()
        {
            base.CleanEntity();
        
            m_Tag = null;

            m_Openings = null;

            m_FillsOpening = null;
        }