ifcopenshell.api.group

Submodules

Package Contents

ifcopenshell.api.group.add_group(file, Name='Unnamed', Description=None) None

Adds a new group

An IFC group is an arbitrary collection of products, which are typically physical. It may be used when there is no other more specific group which may be used. Other types of groups include distribution systems, which group together products that are connected and circulate a medium (such as fluid or electricity), or zones, which group together spaces, or structural load groups, which group together loads for structural analysis, or inventories, which are groups of assets.

Parameters:
  • Name (str, optional) – The name of the group. Defaults to “Unnamed”

  • Description (str, optional) – The description of the purpose of the group.

Returns:

The newly created IfcGroup

Return type:

ifcopenshell.entity_instance

Example:

ifcopenshell.api.run("group.add_group", model, Name="Unit 1A")
ifcopenshell.api.group.assign_group(file: ifcopenshell.file, products: list[ifcopenshell.entity_instance], group: ifcopenshell.entity_instance) ifcopenshell.entity_instance | None

Assigns products to a group

If a product is already assigned to the group, it will not be assigned twice.

Parameters:
Returns:

The IfcRelAssignsToGroup relationship or None if products was empty list.

Return type:

Union[ifcopenshell.entity_instance, None]

Example:

group = ifcopenshell.api.run("group.add_group", model, Name="Furniture")
ifcopenshell.api.run("group.assign_group", model,
    products=model.by_type("IfcFurniture"), group=group)
ifcopenshell.api.group.edit_group(file, group=None, attributes=None) None

Edits the attributes of an IfcGroup

For more information about the attributes and data types of an IfcGroup, consult the IFC documentation.

Parameters:
  • group (ifcopenshell.entity_instance) – The IfcGroup entity you want to edit

  • attributes (dict, optional) – a dictionary of attribute names and values.

Returns:

None

Return type:

None

Example:

group = ifcopenshell.api.run("group.add_group", model, Name="Unit 1A")
ifcopenshell.api.run("group.edit_group", model,
    group=group, attributes={"Description": "All furniture and joinery included in the unit"})
ifcopenshell.api.group.remove_group(file, group=None) None

Removes a group

All products assigned to the group will remain, but the relationship to the group will be removed.

Parameters:

group (ifcopenshell.entity_instance) – The IfcGroup entity you want to remove

Returns:

None

Return type:

None

Example:

group = ifcopenshell.api.run("group.add_group", model, Name="Unit 1A")
ifcopenshell.api.run("group.remove_group", model, group=group)
ifcopenshell.api.group.unassign_group(file: ifcopenshell.file, products: list[ifcopenshell.entity_instance], group: ifcopenshell.entity_instance) None

Unassigns products from a group

If the product isn’t assigned to the group, nothing will happen.

Parameters:
Returns:

None

Return type:

None

Example:

group = ifcopenshell.api.run("group.add_group", model, Name="Furniture")
furniture = model.by_type("IfcFurniture")
ifcopenshell.api.run("group.assign_group", model, products=furniture, group=group)

bad_furniture = furniture[0]
ifcopenshell.api.run("group.unassign_group", model, products=[bad_furniture], group=group)
ifcopenshell.api.group.update_group_products(file, group=None, products=None) None

Sets a group products to be an explicit list of products

Any previous products assigned to that group will have their assignment removed.

Parameters:
Returns:

The IfcRelAssignsToGroup relationship

Return type:

ifcopenshell.entity_instance

Example:

group = ifcopenshell.api.run("group.add_group", model, Name="Furniture")
ifcopenshell.api.run("group.update_group_products", model,
    products=model.by_type("IfcFurniture"), group=group)