mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-11 22:31:55 +00:00
@@ -515,6 +515,22 @@ def regenerate_profile_usage(usecase_path, ifc_file, settings):
|
||||
|
||||
def ensure_material_assigned(usecase_path: str, ifc_file: ifcopenshell.file, settings: dict[str, Any]) -> None:
|
||||
elements = settings["products"]
|
||||
material = settings.get("material")
|
||||
if material:
|
||||
assigned_material = settings["material"]
|
||||
else:
|
||||
material_type: ifcopenshell.util.element.MATERIAL_TYPE = settings["type"]
|
||||
element = elements[0]
|
||||
if material_type == "IfcMaterial":
|
||||
assigned_material = ifcopenshell.util.element.get_material(element, should_inherit=False)
|
||||
assert assigned_material # Type checker.
|
||||
# 1) Material usages just inherit the style from the type material, so can't override it.
|
||||
# 2) If type is Set and no material argument were provided, then Set was just created
|
||||
# and not yet have any IfcMaterials.
|
||||
elif material_type.endswith("Usage") or material_type.endswith("Set"):
|
||||
return
|
||||
elif material_type == "IfcMaterialList":
|
||||
assert False, "Current assign_material implementation requires 'material' argument for IfcMaterialList."
|
||||
|
||||
for element in elements[:]:
|
||||
if element.is_a("IfcElementType"):
|
||||
|
||||
@@ -526,6 +526,10 @@ class Geometry(blenderbim.core.tool.Geometry):
|
||||
return False
|
||||
own_material = ifcopenshell.util.element.get_material(element, should_inherit=False)
|
||||
if own_material:
|
||||
# Material usages just inherit the style from the type material, so can't override it.
|
||||
if own_material.is_a("IfcMaterialUsageDefinition"):
|
||||
return False
|
||||
own_material = ifcopenshell.util.element.get_materials(element, should_inherit=False)[0]
|
||||
inherited_style = cls.get_inherited_material_style(element)
|
||||
style = tool.Material.get_style(own_material) if own_material else None
|
||||
if inherited_style != style:
|
||||
|
||||
@@ -1268,7 +1268,6 @@ class Model(blenderbim.core.tool.Model):
|
||||
after material assignment or material unassignment.
|
||||
"""
|
||||
|
||||
style_object = None
|
||||
if assigned_material:
|
||||
# NOTE: currently only IfcMaterials are supported
|
||||
# for anyone else we just switch representation.
|
||||
@@ -1340,7 +1339,7 @@ class Model(blenderbim.core.tool.Model):
|
||||
occurrences = [
|
||||
e
|
||||
for e in ifcopenshell.util.element.get_types(element_type)
|
||||
if not ifcopenshell.util.element.get_material(e, should_inherit=False)
|
||||
if not tool.Geometry.has_material_style_override(e)
|
||||
]
|
||||
return occurrences
|
||||
|
||||
|
||||
Reference in New Issue
Block a user