material.unassign_material - support batching #4474

This commit is contained in:
Andrej730
2024-04-12 16:15:14 +05:00
parent cd25a50e96
commit 657ff30883
9 changed files with 181 additions and 86 deletions
@@ -324,8 +324,8 @@ class UpdateRepresentation(bpy.types.Operator, Operator):
# We are explicitly casting to a tessellation, so remove all parametric materials.
element_type = ifcopenshell.util.element.get_type(product)
if element_type: # Some invalid IFCs use material sets without a type.
ifcopenshell.api.run("material.unassign_material", tool.Ifc.get(), product=element_type)
ifcopenshell.api.run("material.unassign_material", tool.Ifc.get(), product=product)
ifcopenshell.api.run("material.unassign_material", tool.Ifc.get(), products=[element_type])
ifcopenshell.api.run("material.unassign_material", tool.Ifc.get(), products=[product])
else:
# These objects are parametrically based on an axis and should not be modified as a mesh
return
@@ -551,7 +551,7 @@ def ensure_material_assigned(usecase_path, ifc_file, settings):
def ensure_material_unassigned(usecase_path, ifc_file, settings):
elements = [settings["product"]]
elements = settings["products"]
if elements[0].is_a("IfcElementType"):
elements.extend(ifcopenshell.util.element.get_types(elements[0]))
for element in elements:
+3 -3
View File
@@ -116,12 +116,12 @@ def unassign_material(ifc, material_tool, objects):
inherited_material = material_tool.get_material(element, should_inherit=True)
if material and "Usage" in material.is_a():
element_type = material_tool.get_type(element)
ifc.run("material.unassign_material", product=element_type)
ifc.run("material.unassign_material", products=[element_type])
elif not material and inherited_material:
element_type = material_tool.get_type(element)
ifc.run("material.unassign_material", product=element_type)
ifc.run("material.unassign_material", products=[element_type])
elif material:
ifc.run("material.unassign_material", product=element)
ifc.run("material.unassign_material", products=[element])
def patch_non_parametric_mep_segment(ifc, material_tool, profile_tool, obj):