ifcopenshell.api.pset.assign_pset

Module Contents

ifcopenshell.api.pset.assign_pset.assign_pset(file: ifcopenshell.file, products: list[ifcopenshell.entity_instance], pset: ifcopenshell.entity_instance) ifcopenshell.entity_instance | None

Assign property set to provided elements.

This method can be used to make psets shared by multiple elements.

Parameters:
  • products – Elements (or element types) to assign the pset to.

  • pset – Property set.

Returns:

None if products is empty or has only type elements. IfcRelDefinesByProperties if products contains occurrences.

Example:

element = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
ifcopenshell.api.pset.assign_pset(model, [element], pset)
# Pset is now assigned.
assert ifcopenshell.util.element.get_elements_by_pset(pset) == {element}

element1 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
element2 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
ifcopenshell.api.pset.assign_pset(model, [element1, element2], pset)
# Pset is now shared by multiple elements.
assert ifcopenshell.util.element.get_elements_by_pset(pset) == {element, element1, element2}

# Same for element types.
element_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWallType")
ifcopenshell.api.pset.assign_pset(model, [element_type], type_pset)
# Pset is now assigned to the type.
assert ifcopenshell.util.element.get_elements_by_pset(type_pset) == {element_type}