ifcopenshell.api.root.create_entity#

Module Contents#

class ifcopenshell.api.root.create_entity.Usecase(file, ifc_class='IfcBuildingElementProxy', predefined_type=None, name=None)#

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.entity_instance

Example:

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

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

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

# We have a wall type.
ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWallType")
execute(self)#
handle_2x3_defaults(self, element)#
handle_4_defaults(self, element)#