@@ -346,9 +346,37 @@ def import_type_from_ifc(self, element, context):
346346 ifc_importer = import_ifc .IfcImporter (ifc_import_settings )
347347 ifc_importer .file = self .file
348348 ifc_importer .type_collection = type_collection
349+ self .import_type_materials (element , ifc_importer )
350+ self .import_type_styles (element , ifc_importer )
349351 ifc_importer .create_type_product (element )
350352 ifc_importer .place_objects_in_spatial_tree ()
351353
354+ def import_type_materials (self , element , ifc_importer ):
355+ for rel in element .HasAssociations :
356+ if not rel .is_a ("IfcRelAssociatesMaterial" ):
357+ continue
358+ for material in [e for e in self .file .traverse (rel ) if e .is_a ("IfcMaterial" )]:
359+ if IfcStore .get_element (material .id ()):
360+ continue
361+ blender_material = ifc_importer .create_material (material )
362+ self .import_material_styles (blender_material , material , ifc_importer )
363+
364+ def import_type_styles (self , element , ifc_importer ):
365+ for representation_map in element .RepresentationMaps or []:
366+ for element in self .file .traverse (representation_map ):
367+ if not element .is_a ("IfcRepresentationItem" ) or not element .StyledByItem :
368+ continue
369+ for element2 in self .file .traverse (element .StyledByItem [0 ]):
370+ if element2 .is_a ("IfcSurfaceStyle" ) and not IfcStore .get_element (element2 .id ()):
371+ ifc_importer .create_style (element2 )
372+
373+ def import_material_styles (self , blender_material , material , ifc_importer ):
374+ if not material .HasRepresentation :
375+ return
376+ for element in self .file .traverse (material .HasRepresentation [0 ]):
377+ if element .is_a ("IfcSurfaceStyle" ) and not IfcStore .get_element (element .id ()):
378+ ifc_importer .create_style (element , blender_material )
379+
352380
353381class EnableEditingHeader (bpy .types .Operator ):
354382 bl_idname = "bim.enable_editing_header"
0 commit comments