ifcopenshell.util.shape#

Module Contents#

ifcopenshell.util.shape.tol = 1e-06#
ifcopenshell.util.shape.get_area(geometry)#

Calculates the surface area of the geometry

Parameters

geometry (geometry) – Geometry output calculated by IfcOpenShell

Returns

The surface area.

Return type

float

ifcopenshell.util.shape.get_area_vf(vertices, faces)#

Calculates the surface area given a list of vertices and triangulated faces

Parameters
  • vertices – A list of 3D vertices, such as returned from get_vertices.

  • faces – A list of faces, such as returned from get_faces.

Type

np.array[iterable[float]]

Type

np.array[iterable[int]]

Returns

The surface area.

Return type

float

ifcopenshell.util.shape.get_bbox(vertices)#

Gets the bounding box of vertices

Parameters

vertices – An iterable of vertices

Type

iterable

Returns

The bounding box value represented as a tuple of two numpy arrays. The first holds the bottom left corner and the second holds the top right. E.g. (np.array([minx, miny, minz]), np.array([maxx, maxy, maxz]))

Return type

tuple[np.array[float]]

ifcopenshell.util.shape.get_bbox_centroid(geometry)#

Calculates the bounding box centroid of the geometry

The centroid is in local coordinates relative to the object’s placement.

Parameters

geometry (geometry) – Geometry output calculated by IfcOpenShell

Returns

A tuple representing the XYZ centroid

Return type

tuple[float]

ifcopenshell.util.shape.get_bottom_elevation(geometry)#

Gets the lowest local Z ordinate of the geometry

Parameters

geometry (geometry) – Geometry output calculated by IfcOpenShell

Returns

The Z value

Return type

float

ifcopenshell.util.shape.get_edges(geometry)#

Get all the edges as a numpy array

Results are a nested numpy array e.g. [[e1v1, e1v2], [e2v1, e2v2], …]

Note that although geometry always holds triangulated faces, edges will represent the original tessellation or BRep’s faces, which may be quads or ngons.

Parameters

geometry (geometry) – Geometry output calculated by IfcOpenShell

Returns

A numpy array listing all the edges. Each edge is a numpy array with two vertex indices.

Return type

np.array[np.array[int]]

ifcopenshell.util.shape.get_element_bbox_centroid(element, geometry)#

Calculates the element’s bounding box centroid

The centroid is in global coordinates. Note that if you have the shape, it is more efficient to use get_shape_bbox_centroid.

Parameters
  • element – The element occurrence

  • geometry (geometry) – Geometry output calculated by IfcOpenShell

Type

ifcopenshell.entity_instance.entity_instance

Returns

A tuple representing the XYZ centroid

Return type

tuple[float]

ifcopenshell.util.shape.get_element_bottom_elevation(element, geometry)#

Gets the lowest global Z ordinate of the element

Note that if you have the shape, it is more efficient to use get_shape_bottom_elevation.

Parameters
  • element – The element occurrence

  • geometry (geometry) – Geometry output calculated by IfcOpenShell

Type

ifcopenshell.entity_instance.entity_instance

Returns

The Z value

Return type

float

ifcopenshell.util.shape.get_element_top_elevation(element, geometry)#

Gets the highest global Z ordinate of the element

Note that if you have the shape, it is more efficient to use get_shape_top_elevation.

Parameters
  • element – The element occurrence

  • geometry (geometry) – Geometry output calculated by IfcOpenShell

Type

ifcopenshell.entity_instance.entity_instance

Returns

The Z value

Return type

float

ifcopenshell.util.shape.get_element_vertices(element, geometry)#

Get the element’s vertices as a numpy array

Vertices are in global coordinates. Note that if you have the shape, it is more efficient to use get_shape_vertices.

Results are a nested numpy array e.g. [[v1x, v1y, v1z], [v2x, v2y, v2z], …]

Parameters
  • element – The element occurrence

  • geometry (geometry) – Geometry output calculated by IfcOpenShell

Type

ifcopenshell.entity_instance.entity_instance

Returns

A numpy array listing all the vertices. Each vertex is a numpy array with XYZ coordinates.

Return type

np.array[np.array[float]]

ifcopenshell.util.shape.get_extrusions(element)#

Gets all extruded area solids used to define an element’s model body geometry

Parameters

element – The element occurrence

Type

ifcopenshell.entity_instance.entity_instance

Returns

A list of extrusion representation items

Return type

list[ifcopenshell.entity_instance.entity_instance]

ifcopenshell.util.shape.get_faces(geometry)#

Get all the faces as a numpy array

Faces are always triangulated.

Results are a nested numpy array e.g. [[f1v1, f1v2, f1v3], [f2v1, f2v2, f2v3], …]

Parameters

geometry (geometry) – Geometry output calculated by IfcOpenShell

Returns

A numpy array listing all the faces. Each face is a numpy array with three vertex indices.

Return type

np.array[np.array[int]]

ifcopenshell.util.shape.get_footprint_area(geometry, axis='Z', direction=None)#

Calculates the total footprint (i.e. projected) surface area visible from along an axis

This is typically useful for calculating footprint areas. For example, you might want to calculate the top-down footprint area of a slab, ignoring slopes in the slab.

Surfaces do not need to be exactly perpendicular in the direction of the specified axis. A surface is counted so long as it is visible from that axis.

Note that this calculates the 2D projected area, not the actual surface area. If you want the actual area, use get_side_area.

Parameters
  • geometry (geometry) – Geometry output calculated by IfcOpenShell

  • axis (iterable[float],optional) – Either X, Y, or Z. Defaults to Z.

  • direction – An XYZ iterable (e.g. (0., 0., 1.)). If a direction vector is specified, this overrides the axis argument.

Returns

The surface area.

Return type

float

ifcopenshell.util.shape.get_footprint_perimeter(geometry)#

Calculates the footprint perimeter of the geometry

All faces with a negative Z normal are considered and the distance of all perimeter edges are totaled.

Parameters

geometry (geometry) – Geometry output calculated by IfcOpenShell

Returns

The perimeter length

Return type

float

ifcopenshell.util.shape.get_outer_surface_area(geometry)#

Calculates the outer surface area (i.e. all sides except for top and bottom)

This is typically useful for calculating painted areas of beams which exclude the end faces (at the minimum and maximum local Z).

Parameters

geometry (geometry) – Geometry output calculated by IfcOpenShell

Returns

The surface area.

Return type

float

ifcopenshell.util.shape.get_profiles(element)#

Gets all 2D profiles used in the definition of a parametric shape

Profiles may be retrieved either from material profile sets or from swept solid extrusions. This is useful for later doing 2D take-off from profiles.

Parameters

element – The element occurrence

Type

ifcopenshell.entity_instance.entity_instance

Returns

A list of profiles

Return type

list[ifcopenshell.entity_instance.entity_instance]

ifcopenshell.util.shape.get_shape_bbox_centroid(shape, geometry)#

Calculates the shape’s bounding box centroid

The centroid is in global coordinates. Note that if you do not have the shape, you can use get_element_bbox_centroid.

Parameters
  • shape (shape) – Shape output calculated by IfcOpenShell

  • geometry (geometry) – Geometry output calculated by IfcOpenShell

Returns

A tuple representing the XYZ centroid

Return type

tuple[float]

ifcopenshell.util.shape.get_shape_bottom_elevation(shape, geometry)#

Gets the lowest global Z ordinate of the shape

If you do not have the shape, you can use get_element_bottom_elevation instead.

Parameters
  • shape (shape) – Shape output calculated by IfcOpenShell

  • geometry (geometry) – Geometry output calculated by IfcOpenShell

Returns

The Z value

Return type

float

ifcopenshell.util.shape.get_shape_matrix(shape)#

Formats the transformation matrix of a shape as a 4x4 numpy array

Parameters

shape (shape) – Shape output calculated by IfcOpenShell

Returns

A 4x4 numpy array representing the transformation matrix

Return type

np.array

ifcopenshell.util.shape.get_shape_top_elevation(shape, geometry)#

Gets the highest global Z ordinate of the shape

If you do not have the shape, you can use get_element_top_elevation instead.

Parameters
  • shape (shape) – Shape output calculated by IfcOpenShell

  • geometry (geometry) – Geometry output calculated by IfcOpenShell

Returns

The Z value

Return type

float

ifcopenshell.util.shape.get_shape_vertices(shape, geometry)#

Get the shape’s vertices as a numpy array

Vertices are in global coordinates. If you do not have the shape, you can use get_element_vertices.

Results are a nested numpy array e.g. [[v1x, v1y, v1z], [v2x, v2y, v2z], …]

Parameters
  • shape (shape) – Shape output calculated by IfcOpenShell

  • geometry (geometry) – Geometry output calculated by IfcOpenShell

Returns

A numpy array listing all the vertices. Each vertex is a numpy array with XYZ coordinates.

Return type

np.array[np.array[float]]

ifcopenshell.util.shape.get_side_area(geometry, axis='Y', direction=None)#

Calculates the total surface area of surfaces that are visible from the specified axis

This is typically useful for calculating elevational areas. For example, you might want to calculate the side area of a wall (i.e. only one side, not both).

Surfaces do not need to be exactly perpendicular in the direction of the specified axis. A surface is counted so long as it is visible from that axis.

Note that this calculates the actual area, not the projected 2D area. If you want the projected area, use get_footprint_area.

Parameters
  • geometry (geometry) – Geometry output calculated by IfcOpenShell

  • axis (str) – Either X, Y, or Z. Defaults to Y, which is used for standard walls.

Returns

The surface area.

Return type

float

ifcopenshell.util.shape.get_top_elevation(geometry)#

Gets the highest local Z ordinate of the geometry

Parameters

geometry (geometry) – Geometry output calculated by IfcOpenShell

Returns

The Z value

Return type

float

ifcopenshell.util.shape.get_vertices(geometry)#

Get all the vertices as a numpy array

Vertices are in local coordinates.

Results are a nested numpy array e.g. [[v1x, v1y, v1z], [v2x, v2y, v2z], …]

Parameters

geometry (geometry) – Geometry output calculated by IfcOpenShell

Returns

A numpy array listing all the vertices. Each vertex is a numpy array with XYZ coordinates.

Return type

np.array[np.array[float]]

ifcopenshell.util.shape.get_volume(geometry)#

Calculates the total internal volume of a geometry

Volumes of non-manifold geometry will be unpredictable.

Parameters

geometry (geometry) – Geometry output calculated by IfcOpenShell

Returns

The volume in m3

Return type

float

ifcopenshell.util.shape.get_x(geometry)#

Calculates the X length of the geometry

Parameters

geometry (geometry) – Geometry output calculated by IfcOpenShell

Returns

The X dimension

Return type

float

ifcopenshell.util.shape.get_y(geometry)#

Calculates the Y length of the geometry

Parameters

geometry (geometry) – Geometry output calculated by IfcOpenShell

Returns

The Y dimension

Return type

float

ifcopenshell.util.shape.get_z(geometry)#

Calculates the Z length of the geometry

Parameters

geometry (geometry) – Geometry output calculated by IfcOpenShell

Returns

The Z dimension

Return type

float

ifcopenshell.util.shape.is_x(value, x, tolerance=None)#

Checks whether a value is equivalent to X given a tolerance

Parameters
  • value (float) – Input value

  • x (float) – The value to compare to

  • tolerance (float) – The tolerance to use. Defaults to 1e-6.

Returns

True or false

Return type

bool