ifcopenshell.util.placement

Module Contents

ifcopenshell.util.placement.a2p(o: Iterable[float], z: Iterable[float], x: Iterable[float]) MatrixType

Converts a location, X, and Z axis vector to a 4x4 transformation matrix

IFC uses a right-handed coordinate system, so it is not necessary to provide the Y axis.

Parameters:
  • o (iterable[float]) – The origin (i.e. location) of the matrix

  • z (iterable[float]) – The +Z vector / axis of the matrix

  • x (iterable[float]) – The +X vector / axis of the matrix

Returns:

A 4x4 numpy matrix

Return type:

MatrixType

ifcopenshell.util.placement.get_axis2placement(placement: ifcopenshell.entity_instance) MatrixType

Parses an IfcAxis2Placement (2D or 3D) to a 4x4 transformation matrix

Note that this function only parses a single placement axis. If you want to get the placement of an element instead, element placements often are made out of multiple placement axes or other alternative placement methods. You should use get_local_placement instead.

Parameters:

placement (ifcopenshell.entity_instance) – The IfcLocalPlacement enitity

Returns:

A 4x4 numpy matrix

Return type:

MatrixType

ifcopenshell.util.placement.get_cartesiantransformationoperator3d(inst: ifcopenshell.entity_instance) MatrixType

Parses an IfcCartesianTransformationOperator into a 4x4 transformation matrix

Note that in general you will not need to call this directly. See get_mappeditem_transformation instead.

Parameters:

item (ifcopenshell.entity_instance) – The IfcCartesianTransformationOperator entity

Returns:

A 4x4 numpy transformation matrix

Return type:

MatrixType

ifcopenshell.util.placement.get_local_placement(placement: ifcopenshell.entity_instance | None = None) MatrixType

Parse a local placement into a 4x4 transformation matrix

This is typically used to find the location and rotation of an element. The transformation matrix takes the form of:

[ [ x_x, y_x, z_x, x   ]
  [ x_y, y_y, z_y, y   ]
  [ x_z, y_z, z_z, z   ]
  [ 0.0, 0.0, 0.0, 1.0 ] ]

Example:

placement = file.by_type("IfcBeam")[0].ObjectPlacement
matrix = ifcopenshell.util.placement.get_local_placement(placement)
Parameters:

placement (ifcopenshell.entity_instance, optional) – The IfcLocalPlacement entity

Returns:

A 4x4 numpy matrix

Return type:

MatrixType

ifcopenshell.util.placement.get_mappeditem_transformation(item: ifcopenshell.entity_instance) MatrixType

Parse an IfcMappedItem into a 4x4 transformation matrix

Mapped items take a representation with an origin and transform them with a cartesian transformation operation. This function returns the final transformation matrix.

Parameters:

item (ifcopenshell.entity_instance) – The IfcMappedItem entity

Returns:

A 4x4 numpy transformation matrix

Return type:

MatrixType

ifcopenshell.util.placement.get_storey_elevation(storey: ifcopenshell.entity_instance) float

Get the Z elevation in project units of a buildling storey

Building storeys store elevation in two possible locations: the Z value of its placement, or as a fallback the Elevation attribute.

Parameters:

storey (ifcopenshell.entity_instance) – The IfcBuildingStorey entity

Returns:

The elevation in project units

Return type:

float

ifcopenshell.util.placement.rotation(angle: float, axis: Literal['X', 'Y', 'Z'], is_degrees=True) MatrixType

Create a 4x4 numpy matrix representing an euler rotation

Parameters:
  • angle (float) – The angle of rotation

  • axis (str) – The axis to rotate around, either X, Y, or Z.

  • is_degrees (bool) – Whether or not the angle is specified in degrees or radians. Defaults to true (i.e. degrees).

Returns:

A 4x4 numpy rotation matrix

Return type:

MatrixType

ifcopenshell.util.placement.MatrixType

npt.NDArray[np.float64]