/// <summary>
        /// Processes IfcProductRepresentation attributes.
        /// </summary>
        /// <param name="ifcProductRepresentation">The IfcProductRepresentation handle.</param>
        protected override void Process(IFCAnyHandle ifcProductRepresentation)
        {
            base.Process(ifcProductRepresentation);

            Name = IFCImportHandleUtil.GetOptionalStringAttribute(ifcProductRepresentation, "Name", null);

            Description = IFCImportHandleUtil.GetOptionalStringAttribute(ifcProductRepresentation, "Description", null);

            List <IFCAnyHandle> representations =
                IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcProductRepresentation, "Representations");

            if (representations != null)
            {
                foreach (IFCAnyHandle representationHnd in representations)
                {
                    try
                    {
                        IFCRepresentation representation = IFCRepresentation.ProcessIFCRepresentation(representationHnd);
                        if (representation != null)
                        {
                            if (representation.RepresentationItems.Count > 0 || representation.BoundingBox != null)
                            {
                                Representations.Add(representation);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        string msg = ex.Message;
                        // Ignore some specific errors.
                        if (msg != null)
                        {
                            if (!msg.Contains("not imported"))
                            {
                                Importer.TheLog.LogError(Id, msg, false);
                            }
                        }
                    }
                }
            }

            if (IFCImportFile.TheFile.SchemaVersion >= IFCSchemaVersion.IFC2x3)
            {
                if (IFCAnyHandleUtil.IsSubTypeOf(ifcProductRepresentation, IFCEntityType.IfcMaterialDefinitionRepresentation))
                {
                    IFCAnyHandle representedMaterial = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcProductRepresentation, "RepresentedMaterial", false);
                    if (!IFCAnyHandleUtil.IsNullOrHasNoValue(representedMaterial))
                    {
                        RepresentedMaterial = IFCMaterial.ProcessIFCMaterial(representedMaterial);
                    }
                }
            }
        }
        protected override void Process(IFCAnyHandle ifcMaterialConstituent)
        {
            base.Process(ifcMaterialConstituent);

            IFCAnyHandle ifcMaterial = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcMaterialConstituent, "Material", true);

            if (!IFCAnyHandleUtil.IsNullOrHasNoValue(ifcMaterial))
            {
                Material = IFCMaterial.ProcessIFCMaterial(ifcMaterial);
            }

            Name        = IFCImportHandleUtil.GetOptionalStringAttribute(ifcMaterialConstituent, "Name", null);
            Description = IFCImportHandleUtil.GetOptionalStringAttribute(ifcMaterialConstituent, "Description", null);
            double fraction = IFCImportHandleUtil.GetOptionalRealAttribute(ifcMaterialConstituent, "Fraction", -1);

            if (fraction >= 0)
            {
                Fraction = fraction;
            }
            Category = IFCImportHandleUtil.GetOptionalStringAttribute(ifcMaterialConstituent, "Category", null);
            return;
        }
Example #3
0
        protected override void Process(IFCAnyHandle ifcMaterialList)
        {
            base.Process(ifcMaterialList);

            IList <IFCAnyHandle> ifcMaterials =
                IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcMaterialList, "Materials");

            if (ifcMaterials == null)
            {
                IFCImportFile.TheLog.LogError(ifcMaterialList.Id, "Expected at least 1 IfcMaterial, found none.", false);
                return;
            }

            foreach (IFCAnyHandle ifcMaterial in ifcMaterials)
            {
                IFCMaterial material = IFCMaterial.ProcessIFCMaterial(ifcMaterial);
                if (material != null)
                {
                    Materials.Add(material);
                }
            }
        }
Example #4
0
        /// <summary>
        /// Processes IfcRelAssociatesMaterial.
        /// </summary>
        /// <param name="ifcRelAssociatesMaterial">The IfcRelAssociatesMaterial handle.</param>
        void ProcessIFCRelAssociatesMaterial(IFCAnyHandle ifcRelAssociatesMaterial)
        {
            IFCAnyHandle ifcMaterialSelect = IFCAnyHandleUtil.GetInstanceAttribute(ifcRelAssociatesMaterial, "RelatingMaterial");

            if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcMaterialSelect))
            {
                IFCImportFile.TheLog.LogNullError(IFCEntityType.IfcRelAssociatesMaterial);
                return;
            }

            // Deal with various types of IFCMaterialSelect.
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcMaterialSelect, IFCEntityType.IfcMaterial))
            {
                MaterialSelect = IFCMaterial.ProcessIFCMaterial(ifcMaterialSelect);
            }
            else if (IFCAnyHandleUtil.IsSubTypeOf(ifcMaterialSelect, IFCEntityType.IfcMaterialLayer))
            {
                MaterialSelect = IFCMaterialLayer.ProcessIFCMaterialLayer(ifcMaterialSelect);
            }
            else if (IFCAnyHandleUtil.IsSubTypeOf(ifcMaterialSelect, IFCEntityType.IfcMaterialLayerSet))
            {
                MaterialSelect = IFCMaterialLayerSet.ProcessIFCMaterialLayerSet(ifcMaterialSelect);
            }
            else if (IFCAnyHandleUtil.IsSubTypeOf(ifcMaterialSelect, IFCEntityType.IfcMaterialLayerSetUsage))
            {
                MaterialSelect = IFCMaterialLayerSetUsage.ProcessIFCMaterialLayerSetUsage(ifcMaterialSelect);
            }
            else if (IFCAnyHandleUtil.IsSubTypeOf(ifcMaterialSelect, IFCEntityType.IfcMaterialList))
            {
                MaterialSelect = IFCMaterialList.ProcessIFCMaterialList(ifcMaterialSelect);
            }
            else
            {
                IFCImportFile.TheLog.LogUnhandledSubTypeError(ifcMaterialSelect, "IfcMaterialSelect", false);
            }
        }