Example #1
0
        private Ifc4.IfcClassificationReference GetIfcClassificationReferenceFromIfcPropertySetTemplate(Ifc4.IfcPropertySetTemplate ifcPropertySetTemplate)
        {
            //<IfcRelAssociatesClassification id="i999" GlobalId="09Yj_c95H5iPvgszfwsNL6" Name="423.17 - Heizkörper zu IfcClassificationReference">
            //  <RelatedObjects>
            //    <IfcPropertySetTemplate ref="i992" xsi:nil="true" />
            //    <IfcPropertySetTemplate ref="i993" xsi:nil="true" />
            //  </RelatedObjects>
            //  <RelatingClassification>
            //    <IfcClassificationReference ref="i991" xsi:nil="true" />
            //  </RelatingClassification>
            //</IfcRelAssociatesClassification>
            Ifc4.IfcClassificationReference ifcClassificationReference;

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

            if (m_IfcClassificationReferenceFromIfcPropertySetTemplateId.TryGetValue(ifcPropertySetTemplate.Id, out ifcClassificationReference))
            {
                return(ifcClassificationReference);
            }

            IEnumerable <Ifc4.IfcRelAssociatesClassification> ifcRelAssociatesClassificationCollection = Get <Ifc4.IfcRelAssociatesClassification>();
            var relatingClassification = (from ifcRelAssociatesClassification in ifcRelAssociatesClassificationCollection
                                          from relatedObjects in ifcRelAssociatesClassification.RelatedObjects.Items.OfType <Ifc4.IfcPropertySetTemplate>()
                                          where relatedObjects.Ref == ifcPropertySetTemplate.Id
                                          select ifcRelAssociatesClassification.RelatingClassification.Item).FirstOrDefault();

            ifcClassificationReference = relatingClassification as Ifc4.IfcClassificationReference;
            if (ifcClassificationReference != null)
            {
                ifcClassificationReference = Get <Ifc4.IfcClassificationReference>().FirstOrDefault(item => item.Id == ifcClassificationReference.Ref);
            }
            m_IfcClassificationReferenceFromIfcPropertySetTemplateId.Add(ifcPropertySetTemplate.Id, ifcClassificationReference);
            return(ifcClassificationReference);
        }
Example #2
0
 public bool TryGetIfcClassificationReferenceFromIfcPropertySetTemplate(string ifcGlobalId, out Ifc4.IfcClassificationReference ifcClassificationReference)
 {
     Ifc4.IfcPropertySetTemplate ifcPropertySetTemplate = GetIfcPropertySetTemplate(ifcGlobalId);
     ifcClassificationReference = GetIfcClassificationReferenceFromIfcPropertySetTemplate(ifcPropertySetTemplate);
     return(ifcClassificationReference != null);
 }