ifcopenshell.api.material.reorder_set_item

Module Contents

ifcopenshell.api.material.reorder_set_item.reorder_set_item(file: ifcopenshell.file, material_set: ifcopenshell.entity_instance, old_index: int = 0, new_index: int = 0) None

Reorders an item in a material set

In some material sets, the order have meaning, like in a layer set. In other cases, it is purely for human convenience.

Parameters:
  • material_set (ifcopenshell.entity_instance) – The IfcMaterialSet which you want to reorder an item in.

  • old_index (int) – The index of the item you want to move. This starts counting from 0.

  • new_index (int) – The index of the new position the item will move to. This starts counting from 0.

Returns:

None

Return type:

None

Example:

material_set = ifcopenshell.api.material.add_material_set(model,
    name="Window", set_type="IfcMaterialList")

aluminium = ifcopenshell.api.material.add_material(model, name="AL01", category="aluminium")
glass = ifcopenshell.api.material.add_material(model, name="GLZ01", category="glass")

# Now let's use those materials as two items in our list.
ifcopenshell.api.material.add_list_item(model, material_list=material_set, material=aluminium)
ifcopenshell.api.material.add_list_item(model, material_list=material_set, material=glass)

# Switch the order around, this has no meaning for a list, so this
# is just for fun.
ifcopenshell.api.material.reorder_set_item(model,
    material_set=material_set, old_index=0, new_index=1)