ifcopenshell.api.material.unassign_material

Module Contents

class ifcopenshell.api.material.unassign_material.Usecase
execute()
remove_material_usages_from_types() None
unassign_materials() None
ifcopenshell.api.material.unassign_material.unassign_material(file: ifcopenshell.file, products: list[ifcopenshell.entity_instance]) None

Removes any material relationship with the list of products

A product can only have one material assigned to it, which is why it is not necessary to specify the material to unassign. The material is not removed, only the relationship is removed.

If the product does not have a material, nothing happens.

Parameters:

products – The list IfcProducts that may or may not have a material

Returns:

None

Return type:

None

Example:

concrete = ifcopenshell.api.material.add_material(model, name="CON01", category="concrete")

# Let's imagine a concrete bench made out of concrete.
bench_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurnitureType")
ifcopenshell.api.material.assign_material(model,
    products=[bench_type], type="IfcMaterial", material=concrete)

# Let's change our mind and remove the concrete assignment. The
# concrete material still exists, but the bench is no longer made
# out of concrete now.
ifcopenshell.api.material.unassign_material(model, products=[bench_type])