mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 02:47:48 +00:00
fix issues assigning material sets and material lists
This commit is contained in:
@@ -118,7 +118,6 @@ def assign_material(
|
||||
continue
|
||||
|
||||
ifc.run("material.assign_material", products=[element], type=material_type, material=material)
|
||||
material_tool.ensure_material_assigned(elements=[element], material_type=material_type, material=material)
|
||||
assigned_material = material_tool.get_material(element)
|
||||
assert assigned_material # Type checker.
|
||||
|
||||
@@ -128,6 +127,7 @@ def assign_material(
|
||||
material_tool.add_material_to_set(material_set=material, material=default_material)
|
||||
elif material_tool.is_a_material_set(assigned_material):
|
||||
material_tool.add_material_to_set(material_set=assigned_material, material=material)
|
||||
material_tool.ensure_material_assigned(elements=[element], material_type=material_type, material=material)
|
||||
|
||||
|
||||
def unassign_material(ifc: tool.Ifc, material_tool: tool.Material, objects: list[bpy.types.Object]) -> None:
|
||||
|
||||
@@ -321,7 +321,8 @@ class Material(blenderbim.core.tool.Material):
|
||||
) -> None:
|
||||
"""Ensure blender materials are updated after a material assignment.
|
||||
|
||||
Designed to be called after material.assign_material API call."""
|
||||
Designed to be called after material.assign_material API call.
|
||||
For material sets it should be called after some item is already added to the material set."""
|
||||
|
||||
# NOTE: adding/editing/removing layers/profiles/constituents is not supported.
|
||||
# Adding support for profiles/layers it only will be possible when we'll be adding styles
|
||||
|
||||
@@ -1308,7 +1308,8 @@ class Model(blenderbim.core.tool.Model):
|
||||
|
||||
obj = next(iter(mesh_users))
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
own_material = ifcopenshell.util.element.get_material(element, should_inherit=False)
|
||||
assert element # Type checker.
|
||||
own_material = next(iter(ifcopenshell.util.element.get_materials(element, should_inherit=False)), None)
|
||||
inherited_mstyle = tool.Geometry.get_inherited_material_style(element)
|
||||
|
||||
if assigned_material:
|
||||
|
||||
@@ -74,6 +74,9 @@ def assign_material(
|
||||
:param material: The IfcMaterial or material set you are assigning here.
|
||||
If type is Usage then no need to provide `material`, it will be deduced
|
||||
from the element type automatically.
|
||||
If IfcMaterial is provided as material and type is not IfcMaterial,
|
||||
provided material will be ignored except for IfcMaterialList
|
||||
where it will be used as part of the list.
|
||||
:type material: ifcopenshell.entity_instance, optional
|
||||
:return: IfcRelAssociatesMaterial entity
|
||||
or a list of IfcRelAssociatesMaterial entities
|
||||
|
||||
Reference in New Issue
Block a user