public static IFCAnyHandle GetOrCreateMaterialSet(ExporterIFC exporterIFC, FamilySymbol familySymbol, IFCAnyHandle typeStyle, MaterialAndProfile materialAndProfile) { IFCFile file = exporterIFC.GetFile(); ElementId typeId = familySymbol.Id; IFCAnyHandle materialSet = ExporterCacheManager.MaterialSetCache.Find(typeId); if (materialSet == null && materialAndProfile != null) { IList <IFCAnyHandle> matProf = new List <IFCAnyHandle>(); foreach (KeyValuePair <ElementId, IFCAnyHandle> MnP in materialAndProfile.GetKeyValuePairs()) { IFCAnyHandle materialHnd = CategoryUtil.GetOrCreateMaterialHandle(exporterIFC, MnP.Key); if (materialHnd != null && ExporterCacheManager.ExportOptionsCache.ExportAs4) { matProf.Add(IFCInstanceExporter.CreateMaterialProfile(file, MnP.Value, Material: materialHnd)); } } if (matProf.Count > 0) { materialSet = IFCInstanceExporter.CreateMaterialProfileSet(file, matProf, name: familySymbol.Name); ExporterCacheManager.MaterialSetCache.Register(typeId, materialSet); } } return(materialSet); }
/// <summary> /// Create or add into exsiting relation for a material set from a family symbol. /// </summary> /// <param name="exporterIFC">the exporter IFC</param> /// <param name="familySymbol">the element family symbol</param> /// <param name="typeStyle">the IFC type object created for the above family symbol</param> /// <param name="materialAndProfile">a dictionary that keeps the association of the material elementid and the associated profile def</param> public static void CreateMaterialAssociation(ExporterIFC exporterIFC, FamilySymbol familySymbol, IFCAnyHandle typeStyle, MaterialAndProfile materialAndProfile) { ElementId typeId = familySymbol.Id; IFCAnyHandle materialSet = GetOrCreateMaterialSet(exporterIFC, familySymbol, typeStyle, materialAndProfile); if (!IFCAnyHandleUtil.IsNullOrHasNoValue(materialSet)) { ExporterCacheManager.MaterialRelationsCache.Add(materialSet, typeStyle); } }