ifcopenshell.api.material.unassign_material#

Module Contents#

class ifcopenshell.api.material.unassign_material.Usecase(file, product=None)#

Removes any material relationship with a product

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

product (ifcopenshell.entity_instance.entity_instance) – The IfcProduct that may or may not have a material

Returns

None

Return type

None

Example:

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

# Let's imagine a concrete bench made out of concrete.
bench_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurnitureType")
ifcopenshell.api.run("material.assign_material", model,
    product=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.run("material.unassign_material", model, product=bench_type)
execute(self)#