BuildingInformationModel

class compas_ifc.bim.BuildingInformationModel(filepath=None, schema='IFC4', use_occ=False, load_geometries=True, rectify_placements=True, rectify_verbose=False, name=None, **kwargs)

Bases: ElementFactoryMixin, InteractionMixin, TreeMixin, Model

A building information model backed by an IFC file.

Extends compas_model.Model to provide IFC-specific functionality including reading/writing IFC files, spatial hierarchy management, and IFC entity creation. The model’s tree holds the spatial hierarchy and the graph holds non-hierarchical relationships (interactions).

This class acts as a bi-directional front-end: every mutation (adding elements, changing geometry/properties/transforms) immediately updates the underlying IFC file. Calling save() writes the file.

IfcProject-level information (units, schema, metadata) is managed directly by this class rather than as a separate element.

Parameters:
filepathstr, optional

Path to an IFC file to load.

schemastr, optional

IFC schema to use when creating a new file. Default is “IFC4”.

use_occbool, optional

Whether to use OpenCascade for geometry. Default is False.

load_geometriesbool, optional

Whether to pre-load geometries during import. Default is True.

rectify_placementsbool, optional

Whether to rewrite IFC placements during import so that each element’s IfcLocalPlacement.PlacementRelTo points to its spatial parent’s placement and RelativePlacement holds the local transform. Default is True.

rectify_verbosebool, optional

If True and rectify_placements is True, print a line for each rectified placement showing what PlacementRelTo changed from and to (e.g. “IfcWall ‘Wall A’: PlacementRelTo IfcBuilding ‘B1’ -> IfcBuildingStorey ‘S1’”). Default is False.

namestr, optional

Name of the model.

Methods

__init__

add_element

Add a GenericElement to the model tree and create its IFC entity.

get_element_by_global_id

Find an element by its IFC GlobalId.

get_elements_by_name

Find all elements with a given name.

get_elements_by_type

Find all elements of a given IFC type (e.g.

remove_element

Remove a GenericElement from the model and the IFC file.

save

Save the IFC file to disk, optionally converting to another schema.

show

Show the model (or specific elements and their children) in compas_viewer.

validate

Validate all elements against information requirements.

Inherited Methods

ToString

Converts the instance to a string.

add_elements

Add a list of elements to the model.

add_group

Add a group to the model.

add_interaction

Add an interaction between two elements of the model.

add_material

Add a material to the model.

add_modifier

Add a modifier between two elements, with one the source of the modifier and the other the target.

add_or_get_material

Add a material to the model or retrieve an existing instance of the same type.

assign_material

Assign a material to an element or a list of elements.

compute_aabb

Compute the axis-aligned bounding box of the datastructure.

compute_bvh

Compute the Bounding Volume Hierarchy (BVH) of the elements for fast collision checks.

compute_collisions

Detect volumetric collisions (interferences) between building elements.

compute_connections

Detect geometric contacts between building elements and add them as connection edges.

compute_contacts

Compute the contacts between the block elements of this model.

compute_kdtree

Compute the KD tree of the elements for fast nearest neighbour queries.

compute_obb

Compute the oriented bounding box of the datastructure.

contacts

copy

Make an independent copy of the data object.

create_beam

Create an IfcBeam and add it to the model.

create_column

Create an IfcColumn and add it to the model.

create_door

Create an IfcDoor and add it to the model.

create_element

Create a building element and add it to the model.

create_roof

Create an IfcRoof and add it to the model.

create_slab

Create an IfcSlab and add it to the model.

create_wall

Create an IfcWall and add it to the model.

create_window

Create an IfcWindow and add it to the model.

element_nnbrs

Find the nearest neighbours to a root element.

elements

Iterate over the elements contained in the model.

export

Export selected elements to a new IFC file.

extract

Extract elements into a new standalone BuildingInformationModel.

find_all_elements_of_type

Find all model elements of a given type.

find_element_with_name

Returns True if the model contains an element with the given name.

find_element_with_name_or_fail

from_json

Construct an object of this type from a JSON file.

from_jsonstring

Construct an object of this type from a JSON string.

get_interactions_by_category

Get all graph edges that have at least one relationship of a given category.

get_interactions_by_group

Get all graph edges belonging to a relationship group.

has_element

Returns True if the model contains the given element.

has_element_with_name

Returns True if the model contains an element with the given name.

has_interaction

Returns True if two elements have an interaction set between them.

has_material

Verify that the model contains a specific material.

materials

Iterate over the materials stored in the model.

point_nnbrs

Find the nearest neighbours to a point.

print_hierarchy

Print the spatial hierarchy of the model.

remove_elements_of_type

Remove all model elements of a given type.

remove_interaction

Remove the interaction between two elements.

rotate

Rotate the datastructure.

rotated

Returns a rotated copy of this geometry.

scale

Scale the datastructure.

scaled

Returns a scaled copy of this geometry.

sha256

Compute a hash of the data for comparison during version control using the sha256 algorithm.

show_collision_pairs

Visualize all collision pairs at once, each pair in its own colour.

show_collisions

Show the model with an interactive collision list in compas_viewer.

template

Create a template BIM model with default spatial hierarchy.

to_json

Convert an object to its native data representation and save it to a JSON file.

to_jsonstring

Convert an object to its native data representation and save it to a JSON string.

trace_connections

Trace elements reachable from start through interaction edges.

transform

Transform the model and all that it contains.

transform_numpy

Transforms the data structure.

transformed

Returns a transformed copy of this data structure.

transformed_numpy

Returns a transformed copy of this data structure.

translate

Translate the datastructure.

translated

Returns a translated copy of this geometry.

validate_data

Validate the data against the object's data schema.