mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
Material based surface styles are now supported on import as a style fallback. See #1585.
This commit is contained in:
@@ -54,9 +54,24 @@ class MaterialCreator:
|
|||||||
if not self.mesh or self.mesh.name in self.parsed_meshes:
|
if not self.mesh or self.mesh.name in self.parsed_meshes:
|
||||||
return
|
return
|
||||||
self.parsed_meshes.add(self.mesh.name)
|
self.parsed_meshes.add(self.mesh.name)
|
||||||
|
self.add_default_material_surface_style(element)
|
||||||
if self.parse_representations(element):
|
if self.parse_representations(element):
|
||||||
self.assign_material_slots_to_faces()
|
self.assign_material_slots_to_faces()
|
||||||
|
|
||||||
|
def add_default_material_surface_style(self, element):
|
||||||
|
element_material = ifcopenshell.util.element.get_material(element)
|
||||||
|
if not element_material:
|
||||||
|
return
|
||||||
|
for material in [m for m in self.ifc_importer.file.traverse(element_material) if m.is_a("IfcMaterial")]:
|
||||||
|
if not material.HasRepresentation:
|
||||||
|
continue
|
||||||
|
surface_style = [
|
||||||
|
s for s in self.ifc_importer.file.traverse(material.HasRepresentation[0]) if s.is_a("IfcSurfaceStyle")
|
||||||
|
]
|
||||||
|
if surface_style:
|
||||||
|
self.mesh.materials.append(self.styles[surface_style[0].id()])
|
||||||
|
return
|
||||||
|
|
||||||
def load_existing_materials(self):
|
def load_existing_materials(self):
|
||||||
for material in bpy.data.materials:
|
for material in bpy.data.materials:
|
||||||
if material.BIMObjectProperties.ifc_definition_id:
|
if material.BIMObjectProperties.ifc_definition_id:
|
||||||
@@ -568,9 +583,7 @@ class IfcImporter:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
checkpoint = time.time()
|
checkpoint = time.time()
|
||||||
self.update_progress(
|
self.update_progress(((total_created / approx_total_products) * progress_range) + start_progress)
|
||||||
((total_created / approx_total_products) * progress_range) + start_progress
|
|
||||||
)
|
|
||||||
shape = iterator.get()
|
shape = iterator.get()
|
||||||
if shape:
|
if shape:
|
||||||
product = self.file.by_id(shape.guid)
|
product = self.file.by_id(shape.guid)
|
||||||
|
|||||||
Reference in New Issue
Block a user