/// <summary>
        /// Creates an association between a material handle and an instance handle.
        /// </summary>
        /// <param name="document">
        /// The Revit document.
        /// </param>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="instanceHandle">
        /// The IFC instance handle.
        /// </param>
        /// <param name="materialId">
        /// The material id.
        /// </param>
        public static void CreateMaterialAssociation(Document doc, ExporterIFC exporterIFC, IFCAnyHandle instanceHandle, ElementId materialId)
        {
            // Create material association if any.
            if (materialId != ElementId.InvalidElementId)
            {
                IFCAnyHandle materialNameHnd = exporterIFC.FindMaterialHandle(materialId);
                if (!materialNameHnd.HasValue)
                {
                    Material material = doc.get_Element(materialId) as Material;
                    if (material != null)
                    {
                        IFCLabel materialName = IFCLabel.Create(material.Name);
                        materialNameHnd = exporterIFC.GetFile().CreateMaterial(materialName);
                        exporterIFC.RegisterMaterialHandle(materialId, materialNameHnd);
                    }
                }

                if (materialNameHnd.HasValue)
                {
                    exporterIFC.RegisterMaterialRelation(materialNameHnd, instanceHandle);
                }
            }
        }