ifcopenshell.api.root.create_entity

Module Contents

class ifcopenshell.api.root.create_entity.Usecase
execute()
handle_2x3_defaults(element)
handle_4_defaults(element)
ifcopenshell.api.root.create_entity.create_entity(file: ifcopenshell.file, ifc_class: str = 'IfcBuildingElementProxy', predefined_type: str | None = None, name: str | None = None) ifcopenshell.entity_instance

Create a new rooted product

This is a critical function used to create almost any rooted product or product type. If you want to create walls, spaces, buildings, wall types, and so on, use this function.

Just specify the class you want to create, as well as the predefined type and name. It will handle the storage of the predefined type and check whether the predefined type is built-in or custom. It will also generate a valid GlobalId and store ownership history. It will also handle some edge cases for default validity where users might forget to populate some mandatory attributes. For example, doors must define an operation type but many people forget.

Parameters:
  • ifc_class (str,optional) – Any rooted IFC class.

  • predefined_type (str,optional) – Any built-in or user-defined predefined type that is applicable to that IFC class. For user-defined predefined types just enter in any value and the API will handle it automatically.

  • name (str,optional) – The name of the new element.

Returns:

The newly created element based on the specified IFC class.

Return type:

ifcopenshell.entity_instance

Example:

# We have a project.
ifcopenshell.api.root.create_entity(model, ifc_class="IfcProject")

# We have a building.
ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuilding")

# We have a wall.
ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")

# We have a wall type.
ifcopenshell.api.root.create_entity(model, ifc_class="IfcWallType")